From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/html/element%2Fpre.html | 183 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 devdocs/html/element%2Fpre.html (limited to 'devdocs/html/element%2Fpre.html') diff --git a/devdocs/html/element%2Fpre.html b/devdocs/html/element%2Fpre.html new file mode 100644 index 00000000..d3143640 --- /dev/null +++ b/devdocs/html/element%2Fpre.html @@ -0,0 +1,183 @@ +

<pre>: The Preformatted Text element

The <pre> HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional, or monospaced, font. Whitespace inside this element is displayed as written.

+

Try it

+
+

If you have to display reserved characters such as <, >, &, and " within the <pre> tag, the characters must be escaped using their respective HTML entity.

+
+

Attributes

+
+

This element only includes the global attributes.

+cols Non-standard Deprecated +

Contains the preferred count of characters that a line should have. It was a non-standard synonym of width. To achieve such an effect, use CSS width instead.

+width Deprecated Non-standard +

Contains the preferred count of characters that a line should have. Though technically still implemented, this attribute has no visual effect; to achieve such an effect, use CSS width instead.

+wrap Non-standard Deprecated +

Is a hint indicating how the overflow must happen. In modern browser this hint is ignored and no visual effect results in its present; to achieve such an effect, use CSS white-space instead.

+
+

Accessibility concerns

+
+

It is important to provide an alternate description for any images or diagrams created using preformatted text. The alternate description should clearly and concisely describe the image or diagram's content.

People experiencing low vision conditions and browsing with the aid of assistive technology such as a screen reader may not understand what the preformatted text characters are representing when they are read out in sequence.

A combination of the <figure> and <figcaption> elements, supplemented by the ARIA role and aria-label attributes on the pre element allow the preformatted ASCII art to be announced as an image with alternative text, and the figcaption serving as the image's caption.

+
+

Example

+
+
+

html

+
<figure>
+  <pre role="img" aria-label="ASCII COW">
+      ___________________________
+  &lt; I'm an expert in my field. &gt;
+      ---------------------------
+          \   ^__^
+           \  (oo)\_______
+              (__)\       )\/\
+                  ||----w |
+                  ||     ||
+  </pre>
+  <figcaption id="cow-caption">
+    A cow saying, "I'm an expert in my field." The cow is illustrated using
+    preformatted text characters.
+  </figcaption>
+</figure>
+
+
+
+

Examples

+ +

Basic example

+
+

HTML

+

html

+
<p>Using CSS to change the font color is easy.</p>
+<pre>
+body {
+  color: red;
+}
+</pre>
+
+

Result

+
+ + +
+
+

Escaping reserved characters

+
+

HTML

+

html

+
<pre>
+let i = 5;
+
+if (i &lt; 10 &amp;&amp; i &gt; 0)
+  return &quot;Single Digit Number&quot;
+</pre>
+
+

Result

+
+ + +
+
+

Technical summary

+
Content categories +Flow content, palpable content.
Permitted content +Phrasing content.
Tag omission None, both the starting and ending tag are mandatory.
Permitted parents Any element that accepts flow content.
Implicit ARIA role generic
Permitted ARIA roles Any
DOM interface HTMLPreElement
+

Specifications

+
+ + +
Specification
HTML Standard
# the-pre-element
+

Browser compatibility

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariWebView AndroidChrome AndroidFirefox for AndroidOpera AndroidSafari on IOSSamsung Internet
pre1121Yes15≤44.418414≤3.21.0
colsNoNo1–29NoNoNoNoNo4–29NoNoNo
width
1Specifying the width attribute has no layout effect.
12Specifying the width attribute has no layout effect.
1Since Firefox 29, specifying the width attribute has no layout effect.
YesSpecifying the width attribute has no layout effect.
15Specifying the width attribute has no layout effect.
3Specifying the width attribute has no layout effect.
4.4Specifying the width attribute has no layout effect.
18Specifying the width attribute has no layout effect.
4Since Firefox 29, specifying the width attribute has no layout effect.
14Specifying the width attribute has no layout effect.
2Specifying the width attribute has no layout effect.
1.0Specifying the width attribute has no layout effect.
wrap16791No1564.41841461.0
+

See also

+
+

+ © 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
+ https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre +

+
-- cgit v1.2.3