Reputation: 50832
I wonder if it is possible to give a span a maximum width. I tried using the following css
display: block;
max-width: 300px;
But the width gets ignored when the text content of the SPAN doesn't fit into the span.
I would like to cut the visible part of the span to the defined max-width. Is this possible?
Any suggestions?
Upvotes: 0
Views: 1674
Reputation: 565
You have to handle the overflow to avoid expanding.
e.g. Adding:
overflow: hidden;
or overflow: auto;
Upvotes: 1
Reputation: 2657
You'll want to use whitespace: nowrap
and overflow: hidden
on your span to force it all on one line and truncate the text.
Upvotes: 2
Reputation: 192
If I use display: inline-block
- the span wraps at 300px or you can use overflow: hidden
as suggested by others.
See: http://jsfiddle.net/U6R2A/
Upvotes: 1