Attributes

Attributes modify the behavior of a element. Attributes allow you to change sizes, colors, specify link locations, and much more. They have two main components:

<name attribute1="value1" attribute2="value2" ...>
  ...(text or more elements go here)...
</name>

“Changing the Background Color” includes an example of using the style attribute to control the background color of the entire webpage. Here’s a second example, the href attribute:

The a element (or, “anchor” element) creates a link to another web page. The href attribute specifies the location, which we set to the value http://www.yahoo.com. If you view the results and select the link “go to Yahoo!”, you will indeed go to Yahoo!.

Note

The style and href attributes are very different beasts. The style attribute is optional, and may be applied to nearly any HTML element in the body. The href attribute is essential for specifying a link location, and only applies to a narrow set of elements.

Attribute Properties

Attributes follow these rules: