Checking Your IDAlong with rules based on tags and classes, there's another type of selector called id. An id is a unique identifier that allows you to be specific in your formatting. You can apply both a class and an id at the same time, as shown in Script 11.5. This allows you to both use the formatting for the class and augment it with the more-specific id formatting that you've defined. If you prefer, you can also use an id selector by itself, without a class. Script 11.5. Applying an id selector to the style.
When an id is used, it's because you need a unique way of identifying a particular object on a page. You've seen ids used throughout this book, as ids are also how JavaScript knows which precise object on the page to manipulate. In this example, a teacher wants to assign a particular character's speech to the students to translate into modern language and so, gives a unique id to each speech. In order to highlight a particular section, all the teacher has to do is to change the id of the selector within the style tag. To add an ID to your style sheet:
Tips
|