Categories
Uncategorized

Crashing IE7

I accidentally crashed IE7. I narrowed down the code to be a CSS issue. It’s surprisingly simple and very annoying.

Code:





Crashes IE7





Link1
Link2


Is span not allow to self close? Lame.

1 reply on “Crashing IE7”

On Mon, 30 Apr 2007, Glen Lipka wrote:

> My IE7 crashes if I look at the following source:

Mine does too, after "thinking" some time. This does not happen if I
remove the <style> element, making the issue CSS-related, but the basic
issue is markup.

>  <a href="">Link1<span /></a>

– –
> It doesn’t crash if I am explicit with <span></span>

According to the XHTML 1.0 specification, you should not use <span /> but
<span></span>. More generally, in XHTML 1.0, the <tagname /> construct
should be used if and only if the element’s content model is EMPTY, i.e.
no content is ever allowed by the syntax rules. Ref.:
http://www.w3.org/TR/xhtml1/#guidelines
(Technically, Appendix C is informative, not normative; but the XML 1.0
specification says: "For interoperability, the empty-element tag SHOULD be
used, and SHOULD only be used, for elements which are declared EMPTY."
Ref.: http://www.w3.org/TR/REC-xml/#sec-starttags )

What happens on IE is that the "/" in <span /> is ignored, treating it as
the lone start tag <span>. If you remove the "/" characters, IE 7 still
crashes.

(IE does not understand XHTML. If you send XHTML to it labelled as
text/html, it will treat it as HTML, or rather the same way it treats
HTML.)


> It doesn’t crash if I only have 1 link.

I guess IE gets confused when it sees two <span> tags with no end tag for
either of them, though only when you ask it to apply your style sheet.

> Is <span /> illegal?

Not in XHTML, but it should not be used in any context where your document
might be processed by old HTML browsers like IE.


> Why would this crash IE7?

Who knows what really happens? But basically you have (when your document
is processed as HTML) two elements that need end tags but don’t have them,
so it’s not surprising that IE crashes when there are style sheets to be
applied to them.



Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Whatya think?