CSS – width not honored on span tag

Span is an inline element and you can therefore not set a width. To set a width you must first set it to a block element with

display:block;

After that you can set a width. Since span is a native inline element, you can use inline-block too and it will even work in IE:

display:inline-block;

Leave a Comment