HTML <pre> widthAttribute
Examples
Preformatted text with a width of 30 characters:
<pre width="30">
The text specifies the width in the pre tag
The text contains spaces and
line breaks
</pre>
The text specifies the width in the pre tag
The text contains spaces and
line breaks
</pre>
Try it Yourself »
Browser Support
![]()
![]()
![]()
![]()
![]()
Only Firefox browser supports the width attribute.
Definition and Usage
HTML5 does not support the <pre> width attribute. Please use CSS instead.
In HTML 4.01, the width attribute of <pre>is deprecated。
The width attribute specifies the maximum number of characters per line.
Compatibility Notes
In HTML 4.01, the width attribute of <pre> is deprecated. Please use CSS instead.
CSS Syntax: <div style="width:200px;overflow:auto"><pre>Some text</pre></div>
CSS Example: Preformatted text with a fixed width
In our CSS tutorial, you can find more details aboutthe width attribute.
Tip:If the width of the text exceeds the width of the surrounding element, the overflow attribute will add a scrollbar.
Syntax
<pre width="number">
Attribute Values
| Value | Description |
|---|---|
| number | Sets the width in number of characters. |
HTML <pre> Tag Other extensions