demosthenes.info

I’m Dudley Storey, the author of Pro CSS3 Animation. This is my blog, where I talk about web design and development with , and . To receive more information, including news, updates, and tips, you should follow me on Twitter.

featured articles

popular favourites

Ozymandius Corp

HTML5 Best Practices For header section and primary navigation

Marking the end-of-semester final sites from my classes, I’m discovering the same basic misunderstandings and bad habits repeated in pages made by many students. Most of the pages are valid, which is a great start, but they’re also incomplete.

While I emphasize best practices in my classes (and elsewhere on this blog), it occurred to me that perhaps they needed to be in one place, or presented in a series of articles. Thus, this entry.

Let’s take the start of a valid, accessible page, shown at the top of this article. This is not yet set up for , nor has it had metadata added to it, but the page is otherwise complete. Here’s the code:

  1. <!DOCTYPE html>
  2. <html lang=en>
  3. <head>
  4. <meta charset=utf-8>
  5. <title>Ozymandius Corp – About Us</title>
  6. <link rel=stylesheet href=styles.css>
  7. </head>
  8. <body>
  9. <div id=wrapper>
  10. <header role=banner>
  11. <h1>
  12. <a href=index.php>
  13. <img src=assets/images/ozymandius-corp.jpg alt="Ozymandius Corp">
  14. </a>
  15. </h1>
  16. <nav>
  17. <a href=index.php accesskey=1>Home</a>
  18. <a href=about.php accesskey=2 class=current-page>About Us</a>
  19. <a href=about.php accesskey=3>Products</a>
  20. </nav>
  21. </header>

What makes this a well-made page?

  1. The least amount of HTML5 neccessary written.

  2. title includes both the name of the company / site and the purpose of the page.

  3. All the CSS rules are placed in a single linked style sheet.

  4. div elements kept to a minimum.

  5. ARIA roles used to make the content accessible.

  6. Whether the logo is an image or text, it is inside a <h1> tag and linked to the index page.

  7. A logical folder structure, with all filenames in lowercase. Local paths used, not absolute.

  8. The logo image has the same text in the banner as the filename and alt value.

  9. Avoidance of unnecessary ids and classes: we can specify the appearance of this content in CSS by using descendant selectors rather than an id.

  10. accesskey conventions used for navigation

  11. class used only where necessary (to highlight the current, active page, not repeatedly applied to sibling elements.

If you believe I've missed anything, or see room for improvement, please let me know!

You must be signed up in order to leave comments.

Ah here is one to possibly add. Consistent naming conventions. If you are going to use lower-case use all lower-case. If you want to use CamelCase then use only CamelCase, dashes, etc. Consistency is key for increasing readability for other developers.

posted by Ian Carson

web developer guide

featured comment

by Aisling Brock in New Business Card Design

what i'm reading

A Feast for Crows: A Song of Ice and Fire: Book Four
A Feast for Crows: A Song of Ice and Fire: Book Four

what i'm watching

Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]
Prometheus: Collector's Edition (Bilingual) [Blu-ray 3D + Blu-ray + DVD + Digital Copy]

what i'm playing

Borderlands
Borderlands

what i'm hearing

Planets
Planets

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.