O'Reilly logo

HTML5 and CSS3: Visual QuickStart Guide, Seventh Edition by Bruce Hyslop, Elizabeth Castro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Naming Elements with a Class or ID

Although it isn’t required, you can give your HTML elements a unique identifier, assign them a particular class (or classes), or both. After doing so, you can apply styles to all elements with a given id or class name. That’s certainly their most popular use, but not their only one (see the tips in this section).

To name an element with a unique id

Within the start tag of the element, type id="name", where name uniquely identifies the element Image. name can be almost anything, as long as it doesn’t start with a number or contain any spaces.

Add a unique id attribute to an element in order to identify it for later ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required