This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.
Smartphone icons created by Freepik - Flaticon
Compared to
, the major difference is that allows to set a width and height on the element. Also, with , the top and bottom margins/paddings are respected, but with they are not. Compared to , the major difference is that does not add a line-break after the element, so the element can sit next to other elements. The following example shows the different behavior of , and :span.a { display: inline; /* the default for span */ width: 100px; height: 100px; padding: 5px; border: 1px solid blue; background-color: yellow; } span.b { display: inline-block; width: 100px; height: 100px; padding: 5px; border: 1px solid blue; background-color: yellow; } span.c { display: block; width: 100px; height: 100px; padding: 5px; border: 1px solid blue; background-color: yellow; }
One common use for
is to display list items horizontally instead of vertically. The following example creates horizontal navigation links:.nav { background-color: yellow; list-style-type: none; text-align: center; padding: 0; margin: 0; } .nav li { display: inline-block; font-size: 20px; padding: 20px; }