Skip to content

24 ways to impress your friends

Vote down?

Drew McLellan

Chris – fair point. Perhaps an ID would be more appropriate on the body tag. However, for the links themselves, it’s conceivable that you could have more than one representation of the selected site section on a page, so a class works for me.

When looking at it from a site-wide point of view, however, it’s often more practical to have a class on the body as each individual page within that site section may have an ID of its own. For example, your Map and Directions page with the Contact section might have a body tag like so:

<body id="map-and-directions" class="contact">...</body>

This would enable you to write specific CSS rules for the layout of that page without having to throw in extra divs and what have you.

So conceptually from a site-wide perspective, you are classifying the page more than you are uniquely identifying it – at least for this purpose.