HTML pre width attribute
Examples
With 30 character width preformatted text:
<Pre width = "30">
Text specifies the width of the pre tag
The text contains spaces and
Wrap
</ Pre>
Text specifies the width of the pre tag
The text contains spaces and
Wrap
</ Pre>
try it"
Browser Support
Only Firefox browser supports the width attribute.
Definition and Usage
HTML5 does not support the <pre> width attribute. Use CSS instead.
In HTML 4.01, <pre> The width attribute obsolete .
width attribute specifies the maximum number of characters per line.
Compatibility Notes
In HTML 4.01, <pre> The width attribute is deprecated. 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 information about the width attribute details.
Tip: If the width of the text exceeds the width of the surrounding elements, overflow property adds a scroll bar.
grammar
<prewidth = "number">
Property Value
值 | 描述 |
---|---|
number | 设置以字符数为单位的宽度。 |
HTML <pre> tag