Attribute 'nowrap' is considered outdated. A newer construct is recommended. What is it?

user1023602 picture user1023602 · May 4, 2012 · Viewed 109k times · Source

I'm getting an error when compiling this within an ASPX page using Visual Studio 2010:

    <td valign="top" nowrap width="237">

The error message is

    "Attribute 'nowrap' is considered outdated. A newer construct is recommended."    

What construct is the error message referring to? And does it behave exactly the same as 'nowrap'?

Answer

Adil picture Adil · May 4, 2012

You can use it like this, I hope you wont get outdated message now.

  <td valign="top" style="white-space:nowrap" width="237">

As pointed by @ThiefMaster it is recommended to put width and valign to CSS (note: CSS calls it vertical-align).

1)

<td style="white-space:nowrap; width:237px; vertical-align:top;">

2) We can make a CSS class like this, it is more elegant way

In style section

.td-some-name
{
  white-space:nowrap;
  width:237px;
  vertical-align:top;
}

In HTML section

<td class="td-some-name">