i use nowrap="nowrap" attribuate to fix my UI for IE 6 , now when i am trying to run the same code in IE 8 its not working.

The code is simple to display table.

nowrap="nowrap" is written in the main CSS file , and its get applied to all site. its working fine with IE6 and 7 , but problem is in IE 8.

In IE8 text in table <td /> displaying in one line and and crossing the window layout.

Can any of you suggest me how to fix it?

Two screenshot are attached.

One is correct Layout display and other one is having problem.

When i am using below code? Page
<td class="itTD" nowrap="nowrap" width="90%" style="padding-right: 0px">
Pgae display is fine with IE6.0 and 7.0.
But not in IE8.0.

Now when i am removing nowrap="nowrap" its fine with IE8 but showing problem in IE6 and 7.

Dani AI

Generated

The overflow you see in IE8 is expected: the td nowrap attribute forces a single unbroken line, so long values spill out of the layout. That attribute is obsolete; standards recommend controlling wrapping via CSS instead. Also note that a valid doctype puts IE8 into Standards mode, which can change table layout behavior compared to IE6/7. (w3c.github.io)

A practical, CSS-first fix is to let very long tokens (URLs, IDs, hashes) break while keeping the table constrained. Drop the HTML nowrap, keep your markup clean, and add rules like these:

/* Keep the table within its container */
table { table-layout: fixed; width: 100%; }

/* Allow long, unbroken strings to wrap instead of overflowing */
td, th { overflow-wrap: break-word; word-wrap: break-word; }

/* Optional: for edge cases with machine-generated IDs only */
.long-ids { word-break: break-all; }

This combination prevents horizontal overflow in modern engines and in old IE that supports word-wrap. Use break-all sparingly since it can split words in the middle. (developer.mozilla.org)

If removing nowrap breaks IE6/7 layouts, isolate those legacy tweaks instead of applying them sitewide. Load an old-IE stylesheet with a conditional comment and keep Standards-mode styles as the default:

<!--[if lte IE 7]>
<link rel="stylesheet" href="/css/ie-old.css">
<![endif]-->

Conditional comments are parsed by IE 5–9 only, so this neatly limits hacks to the browsers that need them. As an emergency fallback, you can force an earlier IE document mode on a specific page with X-UA-Compatible, but prefer the CSS approach above. (quirksmode.org)

+1 to for pointing out the attribute’s deprecation, and to and for steering the fix into CSS. The steps above should keep IE8 from blowing past the window while preserving your IE6/7 layout where required.

Recommended Answers

All 5 Replies

Attach your css file and enter specific properties.
Here is CSS:

#id {
white-space: normal }

And check your validation which version do you use?

CSS and HTML file is attached in mail.

Plz see attachment

CSS and HTML file is attached in mail.

Plz see attachment

I think that you are not understanding the issue here. For so many years, people, not even knowing the meaning of the word, has been yelling and shouting "standards - standards!" ecessively and for so long that it makes me go throw up out from it.

Now: this is STANDARDS and NOWRAP attribute is not standard -threfore - not allowed in standards compliant browser mode!

Nowrap is a HTML3.2 deprecated attribute not avbailable in HTML4 or XHTML and later.

You should use CSS instead or HTML 3.2 DTD for that to work.

CSS and HTML file is attached in mail.

Plz see attachment

Use "white-space:normal" that will solved your issue, and obviously you have to use CSS here for maintain the web standard. Though your file is not that much capable for same right now.

Attached is the file with corrected mentioned issue.

When i am using below code? Page
<td class="itTD" nowrap="nowrap" width="90%" style="padding-right: 0px">

Do it the Standard way - and don't pay attention to kids making jokes on you with white-space: normal.


If you really demand that the text in those TD elements does not wrap and brak in a new line as this code... (

<td class="itTD" nowrap="nowrap" width="90%" style="padding-right: 0px">

)... instructs the quirks mode browsers to do, -
you should correct that into this:

<td class="itTD" style="width:90%; [B]white-space:nowrap;[/B] padding-right: 0px">

That's all!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.