HTML Attributes
25 March 2025 | Category: HTML
HTML Attributes: A Practical Guide
HTML attributes add extra info to elements, written inside the start tag (e.g., <tag attribute="value">). They enhance functionality and style. Let’s explore with examples.
Basic Attribute Example
The <img> tag uses src for the image source and alt for text if it fails to load:

Attributes Demo
Image Test
Built on March 24, 2025.
Links with Attributes
The <a> tag uses href to link somewhere:
Visit Example
Styling with Attributes
The style attribute adds inline CSS:
This text is blue! Smaller heading
Try It
Save the first example as attributes.html (UTF-8 encoding) and open it in a browser. Replace example.jpg with a real image path or URL. Add the <a> or style examples, save, and refresh to see links and styled text.
Why Attributes?
They customize elements—making pages interactive and unique. Experiment with title (e.g., <p title="Hi">Hover me</p>) to see tooltips!
