How do I wrap text in a pre tag?[SOLVED]

Definition and Usage

The pre tag defines preformatted text. 

Before you get to what brought you here, first take a second to under what the pre tag is.Text in this element is displayed in a fixed-width font, and it preserves both spaces and line breaks.

Incase you are wondering on how you can make the text word-wrap inside this pre tag instead of printing out one long line on small screen devices.Then you are in the right place.

Solution.

Place this simple css code in the styling sheet file linked to your webpage.


pre {
    white-space: pre-wrap;       /* Since CSS 2.1 */
    white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
    white-space: -pre-wrap;      /* Opera 4-6 */
    white-space: -o-pre-wrap;    /* Opera 7 */
    word-wrap: break-word;       /* Internet Explorer 5.5+ */
}

 

Hope this post helped you.

collections_bookmark Category :: Css
date_range Published :: 11 months ago At: 10:21 AM
person Writer :: Timothy

YOU MAY LIKE THESE POSTS