How To Make a Web Site the Modern Way. Part 5: The Body – How To Structure Your Markup
by Rob Larsen
Five posts in and finally we get to the heart of the matter- getting your content onto the page for your users to enjoy. This will be done in two parts. This, the first part, will deal with how to structure your HTML so it makes sense from and organizational standpoint and so that you can easily style it with CSS. Let’s look at a stripped down example of what I’m talking about.
<body>
<div id="container">
<div id="header">
<h1>The Site or Company Title- Let's Make a Web Site</h1>
<ul> id="menu"
<li>Imagine this is a Menu</li>
<li>Imagine this is a Menu</li>
</ul>
</div>
<div id="content">
<h2>H2 Header. The content title.</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. <a href="#"><a> Link treatment urna nibh</a>, viverra non, semper suscipit, posuere a, pede. </p>
<h3>H3 Header.Subtopics </h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. <a href="#"><a> Link treatment urna nibh</a>, viverra non, semper suscipit, posuere a, pede. </p>
<h3>H3 Header. Another subtopic. </h3>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. <a href="#"><a> Link treatment urna nibh</a>, viverra non, semper suscipit, posuere a, pede. </p>
</div>
<div id="sidebar">
<div id="ads">This is an ad</div>
</div>
<div id="footer">Released Under the The MIT License. Copyright (c) 2010 Rob Larsen</div>
</div>
</body>
Let’s look at each section in turn.
Container
Some people call this a wrapper. I call it a container. Whatever it is, it’s the outermost div for your site. If you need to constrain the width (to fit in certain view ports), center the design, or apply certain background effects this is where you’ll do it.
It’s just a handy thing to have laying around.
Header
The header is probably what you would expect it to be. Here it simply contains the document (or site) title and a main navigation menu; but in other situations it might also contain a things like the company logo (how we’ll insert that with CSS comes later,) a site slogan (think: WordPress,) or a secondary navigation menu (think “help” or “log in/out.”)
This usage and ID are so prevalent on the web, that the folks behind HTML5 codified it as the new HEADER element.
Content
This is where the- you guessed it- content lives.
As you can see it follows along in an orderly fashion. Starting with an <h2> (to continue from the H1 at the top) at the top and working its way down through a couple of <h3>s. In a larger document you might have several <h3>s and even a few <h4>s. This page itself it a good sample of that.
The idea is to present a logical outline for the page. This helps end users understand and scan the page visually and also helps to educate search engines about the content on the page. This is one of the nice convergences in web development as doing something good for our user also helps search engines understand and rank your content.
The new HTML5 outline
I’ve talked a little bit here and there about HTML5. I won’t go into too much depth about it because for the beginner most of the concepts are the same between the different flavors of HTML. One thing I will mention is that the way you structure your markup, in terms of the way you order your headers, is different in HTML5. In older versions of HTML, you weren’t really supposed to have more than one <h1> element on a page. Because of the way HTML5 documents are structured and owing to some new semantic elements you’re not just allowed, but encouraged to have more than one <h1> if the page requires it. Rewriting the above sample as HTML5, might give you some basic sense of what that means:
<body>
<div id="container">
<header>
<h1>The Site or Company Title- Let's Make a Web Site</h1>
<nav>
<ul id="menu">
<li>Imagine this is a Menu</li>
<li>Imagine this is a Menu</li>
</ul>
</nav>
</header>
<div id="content">
<article>
<h1>H1 Header. The content title.</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. <a href="#"><a> Link treatment urna nibh</a>, viverra non, semper suscipit, posuere a, pede. </p>
<h2>H2 Header.Subtopics </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. <a href="#"><a> Link treatment urna nibh</a>, viverra non, semper suscipit, posuere a, pede. </p>
<h2>H2 Header. Another subtopic. </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. <a href="#"><a> Link treatment urna nibh</a>, viverra non, semper suscipit, posuere a, pede. </p>
</article>
</div>
<aside>
<div id="ads">This is sidebar content</div>
<aside>
<footer>Released Under the The MIT License. Copyright (c) 2010 Rob Larsen</footer>
</footer>
</body>
The new article element allows for the outline to reset, so we start again with an H1 and then move down to an H2, etc. The idea is that it’s a unique block of content and it should be able to repurposed without knowledge of the outline of the containing page.
Sidebar
In this situation, I just have the one sidebar, so I don’t have to worry about any naming issues. It’s just logical, associated content. A sidebar like this will generally have ads, related links, and the like. We’ve segregated it for both logical reasons and to allow us to style it specifically.
In a three column layout, you would have to choose a naming scheme that reflected your content. It might be a menu and a sidebar; ads and menu or some similar variation.
Footer
Copyright, privacy policy, etc. are all usually placed in a footer area. Like the header element, the whatwg created a footer element to capture this common pattern.
- Javascript: Parse Domain Name out of a String
- Code : Javascript : Turn a block into a clickable link area.
- Need/Want to Hide Internet Explorer 6 Specific JavaScript from IE7?
- Cross Browser PNG Transparency: Part 2
- The joy of... JavaScript's getElementsByTagName()
- Javascript: getElementById() for XML fragments and arbitrary XML documents + getElementsByAttribute()
- Mad Science... Flash for a page background using JavaScript and CSS
- Answering Google- Passing a Random Number to a Div id in Javascript
- Cross Browser Opacity using CSS and Internet Explorer filters
- CSS Attribute Selectors. I'd like to be able to use them.
- Display: inline-block is the bee's knees. CSS 2.1
- JSON Feeds For Fun and Profit, Part One- Del.icio.us makes it easy
- JSON Feeds For Fun and Profit Part 2 - Callbacks with Twitter
- The difference between javascript's getElementById() and getElementsByName()
- Automatically Track Outgoing Links in Google Analytics with Javascript
- Did you know- 8 Bit PNG transparency is just like an old school transparent Gif
- A Three Column CSS Layout Using Just an Unordered List
- Belt and Suspenders- Flash Embed With SWFObject and Conditional Comments
- JSON Feeds For Fun and Profit Part 3- wherein Eval() kind of bums me out
- Why Did I Never Try this Before? CSS Font-Size : 0 Hides Input Button Text
- Setting Far Future Expires Headers For Images In Amazon S3
- YSlow Performance Grades for 200 Top Web Sites
- Acid3 Test Released. I Took Some Screen Captures. Lots of Fail.
- Yahoo! Posts an Interesting Illustration of the Lang Attribute.
- Using overflow:auto to Clear Floated Content in CSS
- Best Lightweight Web Server for Serving Static Content?
- Say Hello to JavaScript's Native getElementsByClassName
- Some Internet Explorer Innovations You Probably Forgot About While Waiting for IE6 To Die
- Code I Like: Using Apache's .htaccess and mod_rewrite to Redirect All Traffic to "www"
- Twitter Search Results With JSON and Callbacks
- Code I Like - Link Prefetching
- Two Easy Ways to Get Set Up With Amazon's CloudFront
- Why Front End Performance Matters to Everyone, Not Just the High Traffic Giants
- Code I Like: Batch Subversion Rename (Replace Underscore with Hyphen), Bash Script
- A JavaScript Curiosity Regarding addEventListener
- What This is All About
- Google Releases Page Speed (and I add a few lines to my to-do list)
- HTML5 I'm Using Today- Custom Data Attributes
- On My Radar This Week- Cufon, Event Tracking, Steve Souders' New Book
- I Think I'm Going to Start Dreaming in Wordpress
- Tom Okeefe, Interviewed at Fireworks Designer
- I'm Presenting at the Center for Digital Imaging Arts at Boston University, July 14
- In Case You Missed It- Google Talks Web Performance
- YUI 3.0.0 beta 1 Available for Download
- The Wait For the Palm WebOS SDK
- Recent Reading (HTML5, CSS Fonts, JavaScript, rel=nofollow, Google Analytics)
- getElementsByTagName Namespace Prefix Strangeness in Safari/Chrome/WebKit
- Of Interest- the Google Chrome Operating System
- getElementsByTagNameNS. Now I Know. And Knowing is Half the Battle.
- I Don't Care About Developers. I Care About Users.
- Presentation Done. Thanks to all Who Attended.
- The Palm webOS SDK is Now Open To All. Get Your Mojo On!
- Fun With the :Hover Pseudo Class and Code Samples
- I'm Happy That This One is Live
- Sometimes, Dreamweaver Surprises Me- Great Accessibility Enhancement
- JavaScript Library Showdown. Video of my CDIA Presentation is Live. Check It Out!
- While Twitter is Down...
- Webinar: Increase the Performance of Your Website With Amazon CloudFront
- Even Faster Web Sites (Review)
- How Difficult Is It To Avoid Expensive CSS Selectors?
- Setting Up My Own URL Shortening Service
- An Update on My URL Shortener
- JavaScript Perfromance Tip- Don't Test Against obj.length. Test Against a Local Variable.
- HTML 5 Notes: In Case a Client Asks... No Full Screen Video
- HTML 5 Notes: The Video Element Rocks
- As If URL Shorteners Alone Weren't Bad Enough, Now They've Mated With URL Hijacking Frames
- HTML5 Notes: My First Time Using the Canvas Element
- File Under Cool Tools: Record Page Load Video With WebPageTest
- HTML5 Demo: Tracking Video Progress With Google Analytics
- Why I Dumped Tweetdeck For Brizzly
- HTML5 With Modernizr... Come on in! The Water's Fine.
- I Love You, border-radius. You Too, box-shadow. No, I Didn't Forget About You, rgba Color!
- I'm Finally Building a WebOs App
- Google Chrome Frame- I'll Be Taking Advantage Of It
- I, For One, Welcome Our New CSS3 Overlords. As Long As They Bring box-sizing With Them.
- Thirteen Web Development Tools I Can't Live Without
- More Numbers On the Effect of Page Performance on the Bottom Line
- My Bookshelf. Books on JavaScript, Python, Linux, WebOS, etc.
- Sample HTML Markup Used To Style Common Text Elements
- Default HTML Rendering in 81 Browsers Visualized
- I'm Excited About the New Google Analytics Engagement Goals Feature
- Bing Launches Twitter Search (and I'm Writing About the Real Time Web Over At AWiderNet)
- Have I Mentioned That The HTML5 DOCTYPE Makes Me Smile?
- The JavaScript NodeList and You. Watch Where You Point That Thing, Soldier
- Jscript Versions Reported By Major Versions of Internet Explorer (For Use With Conditional Compilation)
- Netscape's Javascript Documentation From 1999 (document.layers!)
- Playing Around With Twitter Lists
- Google's Sitelinks vs. Bing's Deep Links + D-Card
- Want to Test Your Site Without a Mouse For Accessibility's Sake? These Keyboard Shortcuts Will Help
- Great New Google Webmaster Tools Feature - "Site Performance"
- What I Read This Week (jQuery's live(), algorithms, IE8 + VPN, Chrome )
- Microsoft's CSS Filters, Could The Syntax Be Any Uglier?
- I'm Presenting at WordCamp Boston January 23, 2010
- Browser Size, a Simple But Useful Tool From Google
- If I Lived in The Bay Area, I'd Go To These
- A New Site I Made is Live- AWiderNet.com (HTML5 + CSS3 + Wordpress)
- I'm Resolute
- In Case You Missed It...
- Recent Reading (30 Style Tags?, YUI 3, GodMode, Git, Jira)
- Rethinking the "How To Serve IE-Specific CSS" Question
- I'm Messing Around With an HTML5 Version of the Default Wordpress Theme
- Recent Reading (JavaScript Library CDNs, User-Agent Strings, Hacks, Hacks and Hacks)
- Two Front End Development Interview Questions No One Has Been Getting Recently + One I'm Afraid to Even Ask
- HTML5 + Wordpress Resource Links From my WordCamp Boston Presentation
- Some Photos From WordCamp Boston Posted to Flickr
- Short Notice- I'm Presenting at the Boston JavaScript Meetup This Thursday, January 28, 2010
- My Personal View of Browser Market Share is Pretty Sweet- Firefox Rules, Chrome is Massive, IE6 is Nearly Dead
- Video of My HTML5 + Wordpress Presentation From WordCamp Boston
- My Presentation From Last Night's JavaScript Meetup
- Starter Assets
- How To Make a Web Site the Modern Way. Part 0: Introduction
- How To Make a Web Site the Modern Way. Part 1: The Anatomy of an HTML Page
- Let Me Direct You to the Quote of the Week.
- How To Make a Web Site the Modern Way. Part 2: The Head
- Recent Reading (Analytics, WordPress Short Codes, Jira, JavaScript Videos, Protocol Relative URLS, Facebook)
- I'm on TV. WordPress.TV That Is.
- How To Make a Web Site the Modern Way. Part 3: A Quick Aside on Organizing Files
- How To Make a Web Site the Modern Way. Part 4: The Body
- DrunkenFist.com Redesign Launched. More HTML5 Goodness.
- How To Make a Web Site the Modern Way. Part 5: The Body - How To Structure Your Markup
- I'm Going to be Speaking on Front End Performance in May
- Recent Reading (node.js, P3PC, Event Delegation, Twitter)
- How To Make a Web Site the Modern Way. Part 6: Best Practices for Common HTML Elements (IMG, A)
- A Quick Examination of the Memory and Perfomance Ramifications of CSS Sprite Dimensions
- How To Make a Web Site the Modern Way. Part 7: Best Practices for Lists (UL, OL, DL)
- You Probably Didn't Notice - This Site is Now HTML5
- How To Make a Web Site the Modern Way. Part 8: Tables!
- How To Make a Web Site the Modern Way. Part 9: Tag (and Attribute) Soup
- How To Make a Web Site the Modern Way. Part 10: Forms
- In Case You Missed It:
- How To Make a Web Site the Modern Way. Part 11: The New HTML5 Elements
- Reminder- I'm Presenting on Front End Performance Next Week (May 19)
- Downloads From Last Night's Presentation
- Front End Performance for the Common Man: Practical Strategies to Speed Up Your Site
- Why Do I Like Web Performance? For One Thing, it's Easier to Measure Success
- Performance Tip: When Linking to JavaScript on the Google Ajax Library CDN, Use a Specific Version Number
- I Didn't Make it to Velocity, So Hours of Web Video Will Have to Do
- Required Reading: Yahoo Research on Mobile Cache Size
- I'm Going to Enjoy Writing Code for Internet Explorer 9 (I Can't Believe I Just Typed Those Words)
- Book Review: High Performance JavaScript
- I'm Presenting on CSS in October
- I Added Keyboard Navigation to my Site
- An Ant Task to Comment Out console.log Calls from JavaScript Files
- How To Make a Web Site the Modern Way. Part 12: Cascading Style Sheets
- How To Make a Web Site the Modern Way. Part 13: The Cascade/CSS Specificity
- I'm Going to be Presenting at Design Camp Boston
- HTML5: What You Should Be Using Right Now
- How To Make a Web Site the Modern Way. Part 14: Formatting, Shorthand, Resets and Organization
- Me, Talking About HTML5, Flash, and the Cloud as Part of the Isobar 50
Michel Tadebois Says:
March 18th, 2010 at 4:38 am
Hey Rob, just finished reading that series of article and I must say I can’t way for you to finish them up. It does give a big picture of web design. Great work man. Cheers.
Rob Larsen Says:
March 18th, 2010 at 7:58 am
Thanks Michel,
I’m working on the next installment right now, so it should be ready over the next few days.
This one will have lots of hands on info about different HTML elements, so people should hopefully get a lot out of it.
~Rob