Sponsor: The CSS Anthology

Blog Entry

Best Semantic Naming Convention?

Published on the 15th of October 2008

By Ethan Poole

Awhile back there was a great thread on SitePoint Forums about the best semantic naming convention (external link) for a typical layout shell (header, footer, content, navigation, etc.). A lot of people posted what they thought was the best semantic naming scheme, usually along these lines:

XHTML
<div id="header">
    ...
</div>

<div id="sidebar">
    ...
</div>

<div id="content">
    ...
</div>

<div id="footer">
    ...
</div>

Largely, this is the same semantic naming convention that I would use: header, footer, content, etc. All of these names describe the relation between the various elements of the layout shell. However, I usually try to have the content section above the sidebars for accessibility purposes. Also, many people had an overall wrapper element with the site's name as the ID, but I would recommend to use the <body> element for this.

Surprisingly, a lot of people argued for containers and wrappers (elements used solely to make styling and positioning easier), which are certainly not semantic. However, I guess sometimes you have to sacrifice perfect for near-perfect. Even at Lowter, we use an element called positioning simply for positioning, but this helps to provide a resizable layout that works across browsers. I'd like to remove it from the markup, but it might require having fixed column widths or something else as the cost. Sometimes, with the lack of web standards support in many browsers (mainly IE), it is necessary to sacrifice semantics simply for a better user experience.

With three column layouts, I still cannot really decide on the optimal semantic naming convention. Many people on SitePoint suggested secondary-content and tertiary-content for each sidebar, but this seems to demean one sidebar as more important than the other, which is not always the case. I should also note that sidebar in itself is semantic and the actual definition does not denote that it must be on the "side" of anything as it's name would initially suggest. The best solution I can come up with is simply sidebar_1 and sidebar_2, which just seems ugly. Honestly, the most semantic solution is probably assigning both sidebars a class of sidebar, but this would be unpractical for styling purposes. At Lowter we just use left and right, which of course is not semantic, but simply provide better descriptions than secondary-content and tertiary-content would. This is something that I would like to change in the future, as I am always working to improve the markup on Lowter to make it more semantic whenever possible.

If you would like to share what semantic naming convention you use or your opinion on semantic naming for multiple sub-content column layouts, please feel free to comment below!

Comments

Sponsor: Songbird Media Player

Categories

Use Opera

Opera 9. Innovation delivered. Download Now (external link)

Archives

Author Profile

Ethan Poole

Ethan is a Scandinavian Language student at the University of Minnesota in the Twin Cities. He is a PHP developer and the Managing Director of Lowter. Ethan is a crazy fan of the Opera (external link) web browser and he enjoys foreign language.

All Articles by Ethan