0
HTML · Attributes
New technique
Attributes add detail
A tag says what something is. Sometimes that's not enough: a link also needs to know where it leads.
<a
hrefattribute name
="/halls"value
>Halls</a>
An attribute is an extra setting on an element. It sits inside the opening tag, after the tag name, and it's written as a name, an equals sign and a value in quotes.
The closing tag never gets attributes: it only says “this element ends here”. One element can carry several attributes, separated by spaces.
- Attributes always sit in the opening tag.
- They come as
name="value"pairs. - Their order doesn't matter:
<img src alt>and<img alt src>are the same.