Body onLoad done the separatist way
I'm a big fan of separating content from functionality. Clean semantic markup doesn't have a place for javascript. That's icing. I like to keep to this sequence:
- Start with content
- Markup the content using the appropriate semantic tags
- Begin building your stylesheet to define the character of your presentation
- Add the necessary container elements to allow for the design/layout your going for*Ideally, you can create an effective space without adding extra tags, but this usually isn't realistic.
- Add the layout style to the stylesheet/s
- Build the javascript functionality to augment the site (in a separate file)
- Add any
noscriptsection/s to replace "necessary" functionality - Lather, rinse, repeat
onBlah events and other stuff that doesn't celebrate the content, add the event handlers in a page_init() function. Then add this handy little code snippet to the end of your javascript file to purge that last remnant of markup+code, <body onload="page_init();">:
your_javascript.js
if (window.addEventListener) {
window.addEventListener('load',page_init,false);
} else if (window.attachEvent) {
window.attachEvent('onload',page_init);
}
I won't take credit for this code. I copied it from some site a while back. I can't recall which, though. If I happen across it, I'll link it here.
Now your <body> is clean and fresh.