Content wrapping in Pre tags

Source: Internet
Author: User

<pre> tags to define preformatted text, a common application is used to represent the source code of the computer. Text that is surrounded in the pre element usually retains spaces and line breaks, but unfortunately, when you write code in the <pre> tag, if you do not wrap the line manually, it will also keep it for you, rather than wrapping it automatically.
At this time, you can use Overflow:auto; (The scroll box is displayed when the code is out of bounds of the container), but this method does not apply to all major browsers, and some browsers directly truncate the excess content.

Solution.

Pre {
White-space:pre-wrap; * css-3 * *
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+ * *
}
The CSS scheme allows text to be wrapped in the pre label, and is tested on the browser, all supported, Ie6,ie7, IE8, Firefox, Opera, Safari and Chrome.

Only when you narrow the window to a width of less than 20 characters will the boundary be exceeded.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.