0 0 Votes

CSS: span with a fixed width

Question by Guest | 02/08/2012 at 23:41

I would like to give a <span></span> element a fixed width. However, every browser seems to ignore the assignment. What can I do?

ReplyPositiveNegative

Stefan Trost

Show Profile | Message
Avatar
00 Votes

The <span> element is an inline element, so you can not assign a fixed width to the element as long as it remains an inline element.

You have to set the <span> element to display:block, so that it becomes a block element and only then, it is sensitive to width specifications.

However, with this, several span elements will be displayed below each other (probably you do not want that). To prevent this, you can still float the element with float:left, so it slides to the left.
04/08/2012 at 13:31

ReplyPositive Negative
Reply

Related Topics

CSS Tabulator
Tip | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.