HTML Attributes


An HTML attribute provides additional information about an HTML element. It is always specified in the start tag.

Syntax

<tagname attribute="value">content</tagname>

It is highly recommended to put quotes around attribute values!
We can use either single or double quotes.

Not all attributes need a value to be assigned to them. Some attributes are boolean attributes and do not need a value.

Example: <input type="checkbox" checked>


Examples


Anchor Tag with href Attribute

<a href="https://www.example.com">The href attribute defines the link destination.</a>

The href attribute defines the link destination.


Image Tag with src, alt, and title Attributes

<img src="../images/pepehands.png" alt="Pepehands" title="Pepehands Tooltip">

Pepehands