Anthony Ettinger wrote:

> It works everywhere else (FF, Opera, Safari), but IE7 seems to not
> like the "?" in a url, and wraps it within a table cell.

Stay tuned to seeing other browsers behave that way, too. According to 
Unicode line breaking rules, a break is permitted between a question 
mark "?" and an alphabetic character, even when no space intervenes. 
Although HTML or CSS specifications do not require Unicode conformance, 
there seems to be a trend of changing browsers to apply some of the line 
breaking rules. This is a long story; see
http://www.cs.tut.fi/~jkorpela/html/nobr.html

In practice, this means that there will be more and more situations 
where you want to use either the nonstandard HTML markup 
<nobr>...</nobr> or its CSS counterpart, white-space: nowrap, when your 
text contains special characters (or, as here, punctuation marks in 
contexts other those of a natural language). Despite the name, the 
white-space property affects line breaking in general, not just 
whitespace handling. (Even the CSS 2.1 draft says that "This property 
declares how whitespace inside the element is handled", painting a wrong 
picture, but the description of the nowrap value says "suppresses line 
breaks within text".)

> Markup is a cell in a table like this:
>
> <td class="pan"><a
> href="foo.com?long_url=here">foo.com?long_url=here</a></td>

First of all, in practical terms, it might be best to avoid the problem. 
URLs should be avoided in document content, as opposite to normal 
descriptive link texts. But sometimes you wish to write _about_ URLs, 
and then you need to mention them.

> CSS is:
>
> td.pan { overflow: hidden; width: 12em; }
> td.pan > *:first-child { display: block; overflow: hidden; width:
> 12em; }

Actually this doesn't quite the demonstrate the problem, since your 
sample URL is shorter than 12em, in any normal font. Anyone who wants to 
test your example needs to modify it to see the effect.

> So I tried entity encoding the question mark as "&#60;"

That can't help, since "&#60;" means exactly the same as "?". It is 
converted during the lexical processing of HTML markup, so the 
notational difference cannot have an effect on rendering.

> I also tried { white-space: nowrap; } on the td CSS rule, but that
> didn't do it either...again this is only IE7.

This is where things get really interesting. In a later note you added:
"Adding it to both rules worked"
And in fact, it has the desired effect when placed in the second rule,
td.pan > *:first-child { ... }. You probably first tried it in the first 
one, then added to the second, and didn't check what happens when you 
put it in the second one _only_.

It seems that you have encountered a serious bug in IE 7. By CSS 
specifications, the white-space property is inherited, so the <a> 
element should inherit it from its parent, <td>, since no style sheet 
assigns a white-space value for the <a> element. This seems to be a 
general bug in IE 7. If, for example, we have
<span>foo <i>zip zap</i> bar</span>
and we assign white-space: nowrap to the <span>, then the effect should 
extend to the inner element's content "zip zap" as well. However, IE 7 
breaks between "zip" and "zap" when it sees that fit. Even if we think 
that "suppresses line breaks within text" does not mean _all_ text in 
the content of the element but just directly contained text, inheritance 
rules say that inner elements inherit the value.

However, we could still characterize the IE 7 behavior as "feature, not 
bug", if we (rather articially) describe it so that the browser style 
sheet contains the rule
* { white-space: normal; }
This is different from the fact that normal is the initial value. Such a 
hypothetical browser style sheet prevents any inheritance for the 
white-space property.

This bug has serious implications for any use of white-space: you need 
to set it for inner elements as well. I guess it generally suffices to 
replace
foo { white-space: nowrap; }
by
foo, foo * { white-space: nowrap; }
for any selector foo.

It appears that IE 7 implements <td nowrap> in a manner that does not 
quite correspond to a white-space: nowrap declaration for the cell 
element, as we might expect. It affects whitespace handling but not e.g. 
line breaks after "?". The nonstandard <nobr>...</nobr> markup is more 
effective.

Thus, using the CSS white-space property is the simplest way _provided_ 
that you take a precaution against the lack of inheritance on IE 7.

Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/ 

______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to