Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word-wrapping in IE behaves oddly with leading apostrophe

Status
Not open for further replies.
Dec 8, 2003
17,047
GB
We've run into a problem with both IE6 and IE7 only where adding an apostrophe to the beginning of a word casues the break-point to change rather oddly.

Take this test harness:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
    <title>Word wrap test</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

	<style type="text/css">
		p {
			background-color: red;
			width: 110px;
		}

		.wrapMe {
			word-wrap: break-word;
		}
	</style>
</head>

<body>
	<h3>Leading apostrophe</h3>
	<p>The other 'Enders end has ended..............................</p>
	<p class="wrapMe">The other 'Enders end has ended..............................</p>

	<h3>Non-leading apostrophe</h3>
	<p>The other E'nders end has ended..............................</p>
	<p class="wrapMe">The other E'nders end has ended..............................</p>
</body>
</html>

As you can see, the wrapping point in the second red box is before the word "other", whereas I'd expect it to be the same as the fourth red box where it's after the word "other".

Removing the apostrophe, or changing it for another character (e.g. "2") fixes this.

Because the data on our pages is entered by editors using a CMS, and because we will never know in advance what the content is or how it will wrap, we can't really do any cunning tokenisation or inclusion of "wbr" elements.

We also cannot remove the "break-word" style as we need long words to be forcibly wrapped (see the line of dots at the end of the red boxes).

Is there anything we can do about this, or do we just chalk it up to another IE oddity?

Thanks!

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Left field thought, though havent time to test.

Escape it? & whatever the escape shortcut is ?

as in &amp.

Not brilliant but it jumped into my head.

[blue] A perspective from the other side!![/blue]

Cheers
Scott
 
Well at least I am begining to think the right way. I have a spare 20 or so mins today, I shall give it a go. No promises.

[blue] A perspective from the other side!![/blue]

Cheers
Scott
 
OK well I had a go and I got this following to work.

I reckon its to do with the "break-word".

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">[/URL]
<html>
<head>
    <title>Word wrap test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <style type="text/css">
        p {
            background-color: red;
            width: 110px;
        }

        .wrapMe {
            word-wrap: break-word;
        }
    </style>
</head>

<body>
    <h3>Leading apostrophe</h3>
    <p>The other &#39Enders end has ended..............................</p>
    <p class="wrapMe">The&nbsp;other&nbsp;&#39Enders end has ended..............................</p>

    <h3>Non-leading apostrophe</h3>
    <p>The other E&#39nders end has ended..............................</p>
    <p class="wrapMe">The&nbsp;other&nbsp;E&#39nders end has ended..............................</p>
</body>
</html>

Its a bit messy, I don't like it, but it did the trick for me.

[blue] A perspective from the other side!![/blue]

Cheers
Scott
 
It works, but as mentioned in my original post:

Because the data on our pages is entered by editors using a CMS, and because we will never know in advance what the content is or how it will wrap ...

So basically, including non-breaking spaces (or any other kind of markup) purely to try and get wrapping working in one scenario, is out. The headlines are entered once per article, and are surfaced in multiple places on the site (each place having different width constraints).

That is why I'm after a solution that isn't dependent on the data used.

What strikes me as odd is that is only seems to happen with a few characters (apostrophe, double-quotes), which leads me to believe it's a rendering bug in IE.

Thanks for the continued efforts, though!

Dan




Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I suspect parsing the input will be even messier, Yes I reckon a rendering issue. I did get some strange results with firefox too depending on the escape character.

[blue] A perspective from the other side!![/blue]

Cheers
Scott
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top