When organizing a div layout, my favorite trick is to use the borders on the containers to see visually where they βlandβ on the page, I added this to my sample code.
The trick to getting containers side by side is to use the css float property. This is added to the <div id='navigation'> css properties. Note that the following divs after the floating div will also float. Use the css clear property to put this div back into the inline line (so that it doesn't float). Take unnecessary css as an example and see how the footer jumps towards the content container).
<head> <style type="text/css"> body { background: #dddddd; } div#body { border: 1px solid red; } div#container { border: 1px solid black; } div#navigation { border: 1px solid green; float: left; } div#content { border: 1px solid blue; float: left; width: 900px; } div#shoutout-box { border: 1px solid yellow; } div#notneeded { clear: left; } </style> </head> <body> <div id='body'> <div id='header'>Header</div> <div id='container'> <div id='navigation'>Nav here</div> <div id='content'> <div id='shoutout-box'>Shoutout box</div> Content Div contents here </div> <div id="notneeded"> </div> </div> </div> <div id='footer'>footer</div> </body>
source share