- pre tags are super-useful for code blocks in HTML and for debugging output while writing scripts, but how to make the text word-wrap instead of printing out one long line?
CSS:
[ad type=”banner”]- This works great to wrap text and maintain white-space within the pre-tag:
- Skipping the pre tag and using white-space: pre-wrap on a div is a better solution.
- You can either use this:
- to maintain the monospace font but add word-wrap,
or
- which will allow a fixed size with horizontal scrolling for long lines.
- Try this :
- You can try using this code :
- To get line breaks and shows exact code or text: (chrome, internet explorer, Firefox)
CSS:
[ad type=”banner”]HTML:
This is one of the solution :
[ad type=”banner”]- Text in <pre> tags doesn’t wrap by default. If this is causing layout problems, one solution is to give the pre block an overflow property to hide the excess or cause it to scroll. The other solution is to have it wrap.
- All you need to do is add this one pieces of code to your stylesheet and your text will wrap nicely.
