I’m just wondering what everyones division-naming convention is for division id and class names. We all have our own way of naming things but obviously something that is relevant and generic (i.e. <p class=“highlighted”></p>) rather than something that is targeted (i.e. <p class=“yellowbackground”></p>) is recommended.
How do you name your divisions? Do you use camel casing (i.e. <div id=“mainSiteNav”></div>)? Do you use hyphens (i.e. <div id=“main-site-nav”></div>)? Or maybe you mix them both like Meitar Moscovitz suggests in his article How To Compose HTML ID and Class Names like a Rockstar?
And what do you actually name them? For my own sites it will usually be:
- container / wrapper
- header
- nav
- sidebar
- content
- footer
But after looking at the source code of so many Websites it’s clear that the majority of them name their footers division “footer” and their site navigation as “nav”, “sitenav”, or “navigation”. I’ll be sticking to “nav” because of the nav element in the HTML 5 specification. But what about your main Website container? In fact you might not know what I mean by container, maybe you choose something like:
- container
- wrapper
- masthead
- canvas
- site
- page
- Something else…?
I’m trying to find a convention that I’m happy with and I’m confident that it is semantically correct. Does anyone have any recommendations or suggestions? What convention do you use and why?
I used to use camel casing such as <div id=“mainContainer”></div> but I try and style away from it now, maybe I should return to camel casing. What do you think?
Andrew Cooper