Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Foundations Text, Fonts, and Lists More Text Properties

Why would you ever use no-wrap?

I'm curious. I see how in this video there are methods to bring wrapping back with break-word etc etc. But wouldn't it be best to just leave wrapping in place and style from there?

I don't see why you would remove wrapping if all it will do is take text outside its container. Just curious to hear thoughts on this.

2 Answers

Using white-space: nowrap on text is handy where it concerns text-overflow: ellipsis as it only works on single lines. Other reasons may be for such things as buttons, sometimes it may be 1 or 2px difference between the button breaking onto a new line and not, so while not 100% ideal it can be overcome with this.

John Locke
John Locke
15,479 Points

+1 To this. You can force overflow text to ellipsis by defining the width (you must do this) and white-space: nowrap; overflow: hidden; text-overflow: ellipsis;

Thanks all for your responses! I thought this would be useful for a wordrpess type of situation. I didn't think about buttons. Great stuff!

Julian Price
Julian Price
11,760 Points

I think the best example would be if you want to limit character lengthy of title element that you want to display on a single line. Maybe?

Thanks Julian!