I have a basic two column CSS layout, the CSS looks like
#sidebar {
width:100px;
}
#main {
margin-left:100px;
}
And some sample html
<div id="content">
<div id="sidebar">some sidebar content</div>
<div id="main">some main content</div>
</div>
This works, but it seems repetitive and error prone that the sidebar width needs to match the main’s margin-left value. Is there a better way to do this?
You can use the
floatproperty on#sidebar:JS Fiddle Example
However, using the above method, if the content of
#maincauses its height to extend below#sidebar, it will wrap under the sidebar. To avoid this, use thedisplay:table-cellproperty:JS Fiddle Example