CSS: Set width on inline elements with inline-block

by Yang Yang on August 28, 2009

Share This Article:
Subscribe to Kavoir: blog feed

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.

Share This Article:
Subscribe to Kavoir: blog feed

You should also read:

{ 3 comments… read them below or add one }

Yang Yang August 28, 2009 at 11:48 pm

New theme test…

Reply

Yang Yang August 29, 2009 at 12:32 am

That is interesting

Reply

Yang Yang August 29, 2009 at 12:32 am

Even more interesting

Reply

Leave a Comment

Previous post:

Next post: