English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The pre width attribute specifies the maximum number of characters per line. Only Firefox supports version1.0 to29.0's width attribute.
Formatted text, width of40 characters:
<!DOCTYPE html> <html> <head> <title>HTML: <width> name attribute - Basic Tutorial Website (oldtoolbag.com)</title> </head> <body> <p>Normal pre:</p> <pre> Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks </pre> <p>Define the specific width of Pre:</p> <pre width="40"> Text in a pre element is displayed in a fixed-width font, and it preserves both spaces and line breaks </pre> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
Firefox Supported Version1.0 to29.0's width attribute.
HTML5 The <pre> width attribute is not supported. Please use CSS instead.
In HTML 4.01 In the <pre> tag, the width attribute is deprecated.
The width attribute specifies the maximum number of characters per line.
In HTML 4.01 In the <pre> tag, the width attribute is deprecated. Please use CSS instead.
CSS Syntax:<div style="width:200px;overflow:auto"><pre>Some text</pre></div>
CSS Example: Preformatted text with fixed width
In our CSS tutorial, you can find more about width attribute details.
Tip:If the text width exceeds the width of the surrounding element, the overflow property will add a scrollbar.
<pre width="number">
Value | Description |
---|---|
number | Set the width in number of characters. |