Understanding HTML attributes and how they modify elements
name="value"
. Attributes modify the behavior or appearance of an element, providing extra functionality or information.
Attribute Name
class
, id
, src
)Equals Sign
Attribute Value
<a>
) Attributes<img>
) Attributes<form>
) and Input (<input>
) Attributeschecked
disabled
readonly
required
selected
hidden
open
multiple
autofocus
dataset
property:
onclick
onchange
onsubmit
onload
onkeydown
onmouseover
onfocus
onclick
) is generally discouraged in modern web development. It’s better to separate your JavaScript from your HTML by using event listeners.role
aria-label
aria-labelledby
aria-hidden
aria-expanded
aria-live
aria-required
alt
for images, for
for labels, and ARIA attributes can significantly improve the accessibility of your web pages.loading="lazy"
for images) might not be supported in older browsers. Always check browser compatibility when using newer attributes.
autocomplete
attribute might work differently in Chrome versus Firefox. Test your forms in multiple browsers to ensure consistent behavior.