I have a master div to center all content and such. Inside that div I typically have 3 divs wide worth of content per line, with an occasional line that is 1 div wide. What is the best way to do this layout. Should I just float left all the divs and throw a line break at the end of the line?

2 answers

danwellman 5600
This was chosen as the best answer

You probably don't even need the linebreak, give each <div> that should start on a new line a class name, then feed clear:left to that class and it should cause all div's with that class to drop down on to a new line...

Answered about 8 years ago by danwellman

Add this to your stylesheet:

.clear {

clear: both;
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;


Float your divs. At the end of each row of divs, add this as a divider:
<div class="clear"></div>
A quick and easy way to set up div layouts like this is with a grid system, like 960.gs.

Answered about 8 years ago by Corey McKrill