CSS: span with a fixed width
Question by Guest | 2012-08-02 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?
Related Topics
Fonts for Windows, Linux and Mac on the Web
Article | 0 Comments
CSS: Include CSS Stylesheets in HTML
Tutorial | 0 Comments
Website Performance: Deliver JavaScript and CSS files compressed to reduce loading times
Tutorial | 0 Comments
The Secure Password
Info | 0 Comments
jQuery: CSS Stylesheet Switcher
Tutorial | 1 Comment
Rewrite Text Files with a fixed Line Length
Tutorial | 0 Comments
10 powerful and helping Tips regarding the Yo-Yo-Effect
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 article on askingbox.com. That’s how it’s done.
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.
2012-08-04 at 13:31