Element Attributes

Element Attributes

You can configure your elements by using attributes. Figure shows an attribute that applies to the ‘a’ element. This element lets you create a hyperlink that, when it’s clicked on, loads a different HTML document.

Using an Element Attribute

I like <a href="/apples.html">apples</a> and oranges.

Attributes can be added only to start tags or single tags—they can never be added to end tags. Attributes have a name and a value.

You can apply multiple attributes to an element by separating them with one or more space characters.

Defining Multiple Attributes in an Element

I like <a class="link" href="/apples.html" id="firstlink">apples</a> and oranges.

The order of the attributes is not important, and you can freely mix global attributes with the ones that are element specific, which is what is done above. The class and id attributes are global.