Home >Web Front-end >CSS Tutorial >How Can I Prevent Word Wrapping in HTML?
Eliminating Word Wrapping in HTML
The absence of word wrapping can sometimes be a desired effect within HTML content. Despite the availability of the CSS word-wrap property to force word wrapping with break-word, there is no direct method to disable it.
Solution: Deploying the white-space Attribute
To achieve the desired outcome, implement the CSS white-space attribute. The values white-space: nowrap and white-space: pre are commonly employed for this purpose. White-space: nowrap retains text on a single line, which appears to align with the desired effect.
<br><br>p {<br> white-space: nowrap;<br>}<br><br>
By incorporating this code into your CSS stylesheet, you can effectively disable word wrapping and ensure that your text remains on a single line.
The above is the detailed content of How Can I Prevent Word Wrapping in HTML?. For more information, please follow other related articles on the PHP Chinese website!