How do you prevent text from breaking in css?
Is there a word-wrap or any other attribute that stops text from wrapping? I have a height, and Show Needs to work in all browsers, before CSS3.
isherwood 54.3k15 gold badges105 silver badges147 bronze badges asked Feb 21, 2009 at 4:58
Note: this only works on block elements. If you need to do this to table cells (for example) you need to put a div inside the table cell as table cells have display table-cell not block. As of CSS3, this is supported for table cells as well.
Pluto 2,79727 silver badges36 bronze badges answered Feb 21, 2009 at 5:03
cletuscletus 604k163 gold badges903 silver badges940 bronze badges 5 You can use the CSS
TylerH 21.2k59 gold badges74 silver badges93 bronze badges answered Feb 21, 2009 at 5:04
Robert C. BarthRobert C. Barth 21.9k6 gold badges45 silver badges52 bronze badges Using
TylerH 21.2k59 gold badges74 silver badges93 bronze badges answered Apr 7, 2017 at 10:54
VivekVivek 1,40818 silver badges27 bronze badges 1 Sometimes using
The Codesee 3,6483 gold badges35 silver badges73 bronze badges answered Feb 21, 2009 at 5:01
grossvogelgrossvogel 6,6441 gold badge25 silver badges36 bronze badges 1 Just to be crystal clear, this works nicely with paragraphs and headers etc. You just need to specify For instance:
(forgive the inline styles) answered Jan 26, 2019 at 10:22
Duncan JonesDuncan Jones 64.7k26 gold badges184 silver badges244 bronze badges How do you prevent a line break in CSS?The white-space property has numerous options, all of which define how to treat white space inside a given element. Here, you have set white-space to nowrap , which will prevent all line breaks.
How do I keep text in one line in CSS?If you want to limit the text length to one line, you can clip the line, display an ellipsis or a custom string. All these can be done with the CSS text-overflow property, which determines how the overflowed content must be signalled to the user.
How do you make words not break?Non-Breaking Spaces & Non-Breaking Hyphens
The right solution: keep text together with special characters. Specifically, replace normal spaces and hyphens with non-breaking spaces or non-breaking hyphens: Non-breaking space: [Ctrl] + [Shift] + [Spacebar] Non-breaking hyphen: [Ctrl] + [Shift] + [Hyphen]
How do I stop text break in HTML?Use white-space: nowrap; or give that link more space by setting li 's width to greater values.
|