nowrap (HTML attribute)

Spec
Depr. Version
Yes HTML 3.2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

nowrap="nowrap"

Description

If you need to ensure that the contents of a cell, in this case a table header, always remain as they are, and don’t wrap, use the nowrap attribute. Note that this attribute, which is now deprecated, has a much better alternative in the form of the CSS property white-space (which can be set to "nowrap").

The example HTML shows the nowrap attribute used in an XHTML-compliant way, but it could equally be expressed in HTML 4.01, as follows:

<th nowrap>Car manufacturer (make)</th>

The effect of using this attribute can be seen in Figure 1. Note that it may not always be a wise idea to use nowrap—the image shows a browser window at a reduced size, displaying two versions of the table. In the first version, the nowrap attribute is omitted and the browser reflows the text; in the second version, nowrap forces the text to remain in place, causing the table to disappear off the page, as evidenced by the horizontal scrollbar and missing text.

Figure 1. Two tables, one without, and one with, the nowrap attribute set on the headers Two tables, one without and one with the nowrap attribute set to the table headers

Example

These th contents are set not to wrap:

<th nowrap="nowrap">Car manufacturer (make)</th>

Value

"nowrap" is the only value this attribute can take.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

Excellent browser support is provided for this attribute, but given that this is a deprecated attribute, you should opt for the CSS alternative instead (th {white-space: nowrap;}).

User-contributed notes

There are no comments yet.

Related Products