You are here: Reference > HTML > attributes > cols (pre)

cols attribute (pre)

Browser support:
Specifies the preferred count of characters for each line in a pre element. If a line is longer than the specified character count, the browser tries to wrap it.
The cols attribute is equivalent to the width attribute in Firefox.
For a cross-browser solution use style properties for similar functionality. You can see it in Example 2.

Possible values:

Integer that sets the count of characters.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the cols attribute:
<pre cols="15">The preferred count of characters is 15 for each line.</pre>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates a cross-browser solution instead of the cols attribute:
        .wrapForPre {
             white-space: pre-wrap;
             word-wrap: break-word;
             width: 130px;
    <pre class="wrapForPre">The preferred width is 130px for this field. </pre>
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content