HTML pre width attribute


Preformatted text width a width of 30 characters:
<pre width="30">
Text in a pre element is displayed in a fixed-width
font, and it preserves both     spaces    and
line breaks

Definition and Usage

The width attribute specifies the maximum number of characters per line.

Browser Support

The width attribute is only supported by Firefox.

Compatibility Notes

The width attribute of the pre element was deprecated in HTML 4.01, and is not supported in XHTML 1.0 Strict DTD.
Use CSS instead.
CSS syntax: <div style="width:200px;overflow:auto"><pre>Some text</pre></div>
Tip: The overflow property adds a scrollbar if the width of the text exceeds the width of the surrounding element.


<pre width="number">

Attribute Values

Value Description
number Sets the width in number of characters
HTML pre width attribute Reviewed by 1000sourcecodes on 21:22 Rating: 5
Powered by Blogger.