After taking a break from coding websites, I've realized that HTML5 and CSS have introduced a lot of new features. I typically design sites with a fixed size header and footer, with the main content area in between. The default page should take up 100% of the window height, expanding the content area. If the content is lengthy, a vertical scrollbar will appear as usual.
<body>
<table id="main" ...>
<tr>
<td id="header-and-content">
<div id="header">contains logo, nav and has fixed height</div>
<div id="content">actual content</div>
</td>
</tr>
<tr>
<td id="footer">
fixed size footer
</td>
</tr>
</table>
</body>
Previously, I achieved this layout with the following code:
html, body { height:100% }
table#main { height:100% }
td#footer { height:123px }
However, it seems like this method is now considered obsolete. Can someone who is up to date on the latest markup techniques in 2011 provide some guidance?
UPDATE I understand the importance of semantic markup and using divs. However, my current issue is how to make the footer stay at the bottom of the page even when the content is empty or short. When the content is long, the footer should move down accordingly. Absolute and fixed positioning have not been successful solutions.
SUMMARY OF UPDATES:
- I've experimented with using display:table and display:table-row, which seems to work: little content, more content
- Andrej recommended the method outlined in Make the Footer Stick to the Bottom of a Page, which also works: little content, more content
Despite some success with these methods, I can't help but feel disappointed that the first method still relies on tables and the second method is quite old and hacky. I was hoping for some new, innovative solutions!