Introduction

display: inline-block brought a new way to create side by side boxes that collapse and wrap properly depending on the available space in the containing element. It makes layouts that were previously accomplished with floats easier to create. No need to clear floats anymore.

Compared to <^>display: inline<^>, the major difference is that inline-block allows to set a width and height on the element. Also, with <^>display: inline<^>, top and bottom margins & paddings are not respected, and with <^>display: inline-block<^> they are.

Now, the difference between <^>display: inline-block<^> and <^>display: block<^> is that, with display: block, a line break happens after the element, so a block element doesn't sit next to other elements. Here are some visual examples:

display: inline

display illustration for: display: inline

Notice here how the width and height are not respected, and how the padding top and bottom are present, but overlap over the lines above and under.

				
					
span.box {

  display: inline; /* the default for span */

  width: 100px;

  height: 160px;

  padding: 18px;

}

				
			
				
					&lt;div class="demo_box"&gt;&lt;p&gt;Cheese and wine ricotta danish fontina. Brie cheesy grin paneer squirty cheese taleggio cheesecake &lt;span class="alligator-show-box" style="display: inline; width: 100px; height: 160px; padding: 18px;"&gt;goat taleggio&lt;/span&gt; &lt;span class="alligator-show-box" style="display: inline; width: 100px; height: 160px; padding: 18px;"&gt;goat taleggio&lt;/span&gt;. Bavarian bergkase emmental fromage cheesecake cheese slices cheesy grin queso caerphilly.&lt;/p&gt;&lt;/div&gt;
				
			

display: inline-block

Here the width, height and padding are respected, but the two copies of the element can still sit side by side.

				
					
span.box {

  display: inline-block;

  width: 100px;

  height: 160px;

  padding: 18px;

}

				
			
				
					&lt;div class="demo_box"&gt;&lt;p&gt;Cheese and wine ricotta danish fontina. Brie cheesy grin paneer squirty cheese taleggio cheesecake &lt;span class="alligator-show-box" style="display: inline-block; width: 100px; height: 160px; padding: 18px;"&gt;goat taleggio&lt;/span&gt; &lt;span class="alligator-show-box" style="display: inline-block; width: 100px; height: 160px; padding: 18px;"&gt;goat taleggio&lt;/span&gt;. Bavarian bergkase emmental fromage cheesecake cheese slices cheesy grin queso caerphilly.&lt;/p&gt;&lt;/div&gt;
				
			

display: block

Here again everything is respected, but the elements don't sit side by side.

				
					
span.box {

  display: block;

  width: 100px;

  height: 160px;

  padding: 18px;

}

				
			
				
					&lt;div class="demo_box"&gt;&lt;p&gt;Cheese and wine ricotta danish fontina. Brie cheesy grin paneer squirty cheese taleggio cheesecake &lt;span class="alligator-show-box" style="display: block; width: 100px; height: 160px; padding: 18px;"&gt;goat taleggio&lt;/span&gt; &lt;span class="alligator-show-box" style="display: block; width: 100px; height: 160px; padding: 18px;"&gt;goat taleggio&lt;/span&gt;. Bavarian bergkase emmental fromage cheesecake cheese slices cheesy grin queso caerphilly.&lt;/p&gt;&lt;/div&gt;
				
			

<style>

.demo_box { border: 2px dashed rgba(114, 186, 94, 0.35); background: rgba(114, 186, 94, 0.05); padding:16px; display:flow-root; }

span.box {

display: inline; /* the default for span */

width: 100px;

height: 160px;

padding: 18px;

}

span.box {

display: inline-block;

width: 100px;

height: 160px;

padding: 18px;

}

span.box {

display: block;

width: 100px;

height: 160px;

padding: 18px;

}

.alligator-show-box {

border-radius: 6px;

border: 2px dashed blue;

max-width: 70%;

padding: 1em;

margin-bottom: .4em;

background: whitesmoke;

}

</style>