Text within the pre tag specifies width Text includes spaces"> Text within the pre tag specifies width Text includes spaces" />
Easy Tutorial
❮ Tag Br Att Font Face ❯

HTML <pre> width Attribute

HTML <pre> Tag

Example

Pre-formatted text with a width of 30 characters:

<pre width="30">
Text within the pre tag specifies width
Text includes spaces    and
line breaks
</pre>

Browser Support

Only Firefox supports the width attribute.


Definition and Usage

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. Use CSS instead.

CSS syntax: <div style="width:200px;overflow:auto"><pre>Some text</pre></div>

CSS Example: Pre-formatted text with a fixed width

In our CSS tutorial, you can find more details about the width property.

Tip: The overflow property adds a scrollbar if the text width exceeds the width of the surrounding elements.


Syntax

Attribute Values

Value Description
number Sets the width in number of characters.

❮ Tag Br Att Font Face ❯