Jon
Rohan

I'm a front end web developer living in San Francisco. I have been coding HTML since I was 15. I strive to be the best I can at what I do. I believe in clean and simple design as well as code. This is where I represent myself on the web. I am always looking to form relationships with other amazing people, part time or full time. contact me!

Getting Started with HTML 5

HTML 5 is the next major iteration of HTML, and I know I’m excited about it. I recently added some new HTML 5 markup into dinnermint. It was a very quick and simple change, which I believe will help clear up some of the <div> soup.

The New Tags

There are some new tags in the HTML 5 specification, that I believe will lead to more semantic code. And what I mean by that is the code says what it does. You’re no longer left wondering what those <div> tags are for, when you see a tag like <header> you know what it is for.

The Layout

There are lost of tags I could have used, like aside, audio, video. I plan on playing around with those later, but for now I set up a basic layout consisting of a header, nav, article, footer like so.

<body>
  <header>
    <nav></nav>
  </header>
  <article>
  </article>
  <footer>
  </footer>
</body>

These elements behave like typical block level elements. But are more semantic, if you aren’t sure of the benefits of this check out this post I wrote on CSS class names. If you are thinking about setting up your site, you can at least use header, footer, nav. If you do setup your site, there are a few things you should know.

Add this to your stylesheet, this just reminds the browsers how to display these tags.

header, section, footer,
aside, nav, article, figure {
  display: block;
}

Add this to the Beginning of the <body> tag. This is important for IE browsers, all it is doing is creating an element in the dom for each of the html 5 tags so it doesn’t ignore them. It’s important you place this script before any html 5 tags are used, at the top of the page.

<!--[if IE]>
  <script type="text/javascript">
    (function(){if(!/*@cc_on!@*/0)return;
    var e = "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource," +
    "figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,time,video";.
    split(','),i=e.length;while(i--){document.createElement(e[i])}})()
  </script>
<![endif]-->

If you enjoyed reading this post, check out these posts <!DOCTYPE HTML>, Targeting IE6 for style.

Tags: , , , 01 Sep 2009

About the Author, Jon Rohan

Hey! Thanks for stopping by. I love posting new topics here about various development things. If you liked it follow me on twitter and let me know.

Subscribe to Posts

Add comment