width attribute (pre)
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 will try to wrap it.
Use the width attribute together with the white-space style property in Opera.
The width attribute is equivalent to the cols attribute in Firefox.
For a cross-browser solution, use style properties for similar functionality (see Example 2).
JavaScript page for this attribute: width. You can find other example(s) there. |
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 width attribute:
|
||||
<head> <style> .wrapForPre { white-space: pre-wrap; /* CSS-3 */ } </style> </head> <body> <pre class="wrapForPre" width="15">The preferred count of characters is 15 for each line. </pre> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates a cross-browser solution instead of the width attribute:
|
||||
<head> <style> .wrapForPre { white-space: pre-wrap; word-wrap: break-word; width: 130px; } </style> </head> <body> <pre class="wrapForPre">The preferred width is 130px for this field. </pre> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by tags:
Related pages:
External links:
User Contributed Comments