Attributes go in the opening tag

An attribute is usually written as a name, an equals sign, and a quoted value. An element can have more than one attribute.

<a href="https://www.example.com" title="Visit Example">
  Visit the website
</a>

<img src="cat.jpg" alt="A gray cat" width="300">

<p class="intro" id="welcome">Hello!</p>

Common attributes

  • href gives a link its destination.
  • src gives an image its file location; alt describes the image.
  • class lets CSS style a group of elements; id identifies one element on the page.
  • title provides additional advisory information, often shown as a tooltip.
  • Some attributes are boolean: their presence means “on,” such as disabled on a button.

Learn more