Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Attributes give you a way to specify additional information about an element. While we haven’t looked at attributes in detail, you’ve already seen a few examples of them:
Let’s cook up an example to give you an even better feel for how attributes work:
If <car> was an element, then you’d naturally want to write some markup like this:
But this <car> element only gives a descriptive name for your car – it doesn’t tell us the make, precise model, whether it is a convertible, or a zillion other details we might want to know. So, if <car> were really an element, we might use attributes like this:
Better, right? Now this markup tells us a lot more information in an easy to write, convenient form.