HTMLHTML12 min read

HTML Attributes

Add extra information using attributes like href, src, alt, class, id.

David Miller
December 7, 2025
7.0k343

Attributes give extra details to an element.
They are written inside the opening tag.

Example: link

<a href="https://example.com">Go to Example</a>

Example: image

<img src="photo.jpg" alt="My photo" />

Preview

Go to Example
[Image will show here if file exists]

Most used attributes

  • href (for links)
  • src (for images, scripts)
  • alt (image text)
  • class (group name for CSS)
  • id (unique name)

Rule

id should be unique on the page.

#HTML#Beginner