Skip to Navigation or Skip to Content

Steve Fenton
Author of The Reason Your Website Sucks

HTML 5 Page Layout

You Are Here: Home » Blog » HTML 5 Page Layout

Feeds

RSS Feed

<< June | July | August >>

Saturday, 3rd July 2010

HTML 5 is now just around the corner. I have already tested HTML 5 on a myriad of browsers and with a tiny JavaScript and CSS fix, it works in every major player - so if you are a web developer you need to start thinking about your HTML in a subtly different way.

The big change is that in HTML 5, you can use specific and meaningful containers instead of generic and meaningless div-tags. So instead of having a div for your header, a div for your menu and a div for your content, you can use the header, nav and article tags to really describe your web page.

Below is a really simple example of an HTML 5 page with semantic tags that help to describe the page.

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title>An Example Of Semantic HTML 5</title>
  5. <meta charset="utf-8">
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <meta name="generator" content="Steve Fenton's Fingers">
  8. <meta name="language" content="en">
  9. <meta name="keywords" content="HTML 5, Semantic, Tag, Use">
  10. <meta name="description" content="An example of semantic HTML 5 tag usage">
  11. <meta name="copyright" content="Steve Fenton 2010">
  12. </head>
  13. <body>
  14. <div class="skips">
  15. <a href="#navigation">Skip to Navigation</a> or <a href="#content">Skip to Content</a>
  16. </div>
  17. <h1>An Example Of Semantic HTML 5</h1>
  18. </header>
  19. <nav id="navigation">
  20. <ul>
  21. <li><a href="http://www.stevefenton.co.uk/Content/Home/">Home</a></li>
  22. <li><a href="http://www.stevefenton.co.uk/Content/Blog/">My Blog</a></li>
  23. <li><a href="http://www.stevefenton.co.uk/Content/Contact/">Contact me</a></li>
  24. </ul>
  25. </nav>
  26. <h2>This is an article</h2>
  27. </header>
  28. <section id="content">
  29. <p>If you have any comments on this article, please
  30. <a href="http://www.stevefenton.co.uk/Content/Contact/">contact me</a>!</p>
  31. </aside>
  32. <p>In this example you'll notice that the page has a header and footer of its own, and that each
  33. article (and there can be more than one article on a page) can also have its own header and
  34. footer. Technically in HTML 5, each article header can contain a h1 tag, but for backwards
  35. compatibility it is better to stick with a hierarchical nesting of these tags, which is why this
  36. article has a h2 tag instead.</p>
  37. <p>Each of the new HTML 5 elements in this example can be used just like the good old
  38. (meaningless) "div" tag, except that they mean a lot more to the page. You can style them
  39. exactly you did with "div" tags.</p>
  40. <p>Here is a quick run down of the elements used on the page.</p>
  41. <p>The "header" element is used as a contextual header. It applies to the "article" or web page
  42. that it is contained within.</p>
  43. <p>The "footer" element is also contextual and applies to the "article" or web page that is is
  44. inside of. For a page it might contain copyright information and privacy policy links, for an
  45. article it might contain related links or information about the author of the article.</p>
  46. <p>The "nav" element contains the main page navigation links.</p>
  47. <p>The "article" element contains a unique story or piece of content. The article can be made
  48. up a "header", "section" and "footer".</p>
  49. <p>The "aside" element can be used whenever you want to go off on a tangent or make a related
  50. comment that isn't part of the main article.</p>
  51. <p>This article was written by Steve Fenton</p>
  52. </footer>
  53. <p>&amp;copy; Copyright 2010 Steve Fenton</p>
  54. </footer>
  55. </body>
  56. </html>
  57.