HTML Attributes
Attributes are extra information attached to an element. They live inside the opening tag and follow name="value".
Anatomy of an attribute
<a href="https://example.com" target="_blank">Visit</a>
Every attribute has a name and a value. The value is usually wrapped in double quotes.
Common attributes
href— link destination on<a>src— image or script sourcealt— descriptive text for imagesclass— a CSS hook (many elements can share it)id— a unique identifier
<img src="cat.png" alt="A cat sleeping" class="photo" id="hero-cat" />
Boolean attributes
Some attributes have no value — their presence alone is the value.
<input type="text" disabled />
<button disabled>Not clickable</button>
<input type="checkbox" checked />
disabled— element is not interactivechecked— checkbox starts selectedrequired— field must be filled
data-* attributes
Any attribute prefixed with data- is available to JavaScript and never affects rendering.
<button data-tooltip="Save your work">Save</button>