CSS: Set width on inline elements with inline-block

With display:block elements we can freely set the hard width of them. However for inline elements, width:200px simply won’t work at all. One approach is to float the element which usually causes other problems and isn’t handy at all.

So how to set width to inline elements without floating them in CSS?

The answer is to use this to the CSS rule:

display:inline-block;

Now you can set a width to the inline-ly displayed element and it will extend to the specified width with blank space filling the extra length.

3 thoughts on “CSS: Set width on inline elements with inline-block”

Comments are closed.

Scroll to Top