Html "pre" tag

Source: Internet
Author: User
Definition and usage

The Pre element defines preformatted text. The text enclosed in the PRE element usually preserves spaces and line breaks. The text renders in a fixed-pitch font.
Pre-formatted text can be defined using the pre element. All blank intervals and line breaks of text in the PRE element are retained.

Differences between HTML and XHTML

The "width" attribute of the PRE element was deprecated in HTML 4.01.
The "width" attribute of the PRE element is not supported in html4.01.

The "width" attribute of the PRE element is not supported in XHTML 1.0 strict DTD.
The strict-type DTD of xhtml1.0 no longer supports the "width" attribute in the PRE element.

Notes about <PRE>

It is worth noting that while <XMP> is deprecated, the <PRE> tag does not perform all of the functions of <XMP>:
When <XMP> is not recommended, <PRE> has no value. <PRE> cannot provide the same functions as <XMP>:

<PRE> <B> Hello </B> </PRE> is displayedHello

<XMP> <B> Hello </B> </XMP>: <B> Hello </B>

Instance

Code Output result
<PRE>
This text is
In a fixed-pitch
Font, and it preserves
Both spaces and
Line breaks
</PRE>
This text is
In a fixed-pitch
Font, and it preserves
Both spaces and
Line breaks

Optional attributes

DTDIndicates in which DTD the attribute is allowed. S = strict, t = transitional, and f = frameset.
The DTD column in the following Table specifies the supported DTD attributes. S = strict (accurate), t = transitional (traditional), F = frameset (framework)

Attribute Value Description DTD
Width Number Defines the maximum number of characters per line (usually 40, 80, or 132)
Defines the maximum number of characters acceptable to each row of pre (generally 40, 80 or 132)
TF
Standard attributes

ID, class, title, style, Dir, Lang, XML: Lang, XML: Space

For a full description, go to standard attributes.
View complete attributes

Event attributes

Onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to event attributes.
View complete attributes

Try and demo

Preformatted text
How to control line breaks and spaces with the PRE Tag.
Use pre labels to control line feed and white space

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.