HTML and CSS Reference
Attributes can extend the context and functionality of tags by allowing for the addition of
extra properties to HTML elements. Attributes specify a specific value in the form:
The attribute name/value pair is added right after the reserved word of the opening tag. Some
attributes are used to give necessary information such as where to find an image or where a
link should point to, while others simply help give the element meaning. For example, let
us assume that we want our previous example, the 'Carl Jung' text, to be defined as a link:
However, to define the actual web page to which the link would point, it is necessary to ex-
tend the functionality of the <a> tag with the href attribute. In our example, we want to link
the text to the www.carljung.com web page.
<a href=”http://www.carljung.com”>Carl Jung</a>
Each HTML element has a certain set of valid attributes and valid values for those attributes.
A tag's properties can be expanded upon with more than one attribute. All of the attributes
are included in the same opening tag of the element and are separated with an empty space.
For example, the following code defines both the width and the height of an image.
<img width=”200” height=”100”></img>
Note: End tags never contain any attributes.
A common question concerns the difference between tags and attributes. Generally, attrib-
utes are used when you need to describe the data itself. In other words, if it's data that's
meant to be seen by the end user, it's best to mark it up in an element. If it's data that de-
scribes some other data in the document, it's best to use an attribute.