Menu
HTML Fundamentals
HTML Attributes
Configure elements with attributes like id, class, src, href, alt.
1Using Attributes
Attributes provide extra information about an element. They live inside the opening tag as name="value" pairs.
Example Code
css
<a href="https://example.com" target="_blank" rel="noopener">Visit</a>
<img src="logo.png" alt="Logo" width="120" height="40" />
<input type="email" name="email" required placeholder="you@site.com" />2Put the element in context
Attributes provide details about an element, such as a link destination or an image alternative. Their meaning depends on the element. A boolean attribute is enabled by its presence; writing a string such as false does not generally switch a boolean attribute off.
3Practice with a small page
Give a link an href and an image an alt value, then inspect the DOM attributes. Add and remove disabled on a button. Compare removing the boolean attribute with setting its text to false, and observe the difference in behavior.
Finished reading?
Mark this topic as complete to track progress.