CSS - width not honored on span tag

Width is not honored because span is an inline element. To fix this, add:

display: inline-block;

Depending on your situation, display: inline-block may be better than display: block because any content after the span won't be forced onto a new line.


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;

display: block will not help you here because when float is activated, the elements is automatically switched to block mode, whatever its initial mode, so your width should work.

The problem may be with the empty <span> tag which might not be rendered because of some obscure rule I cannot remember. You should try preventing your span from being empty, maybe by adding a &nbsp; if the content is empty.