inline-block
You can create a grid of boxes that fills the browser width and wraps nicely. This has been possible for a long time using float
, but now with inline-block
it's even easier. inline-block
elements are like inline
elements but they can have a width and height. Let's look at examples of both approaches.
<div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div><div class="box">
I'm floating!
</div>I'm using clear so I don't float next to the above boxes.
</div>The Easy Way (using inline-block)
You can achieve the same effect using the inline-block
value of the display
property.