Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- self-closing tags
- David Schwartz
April 22, 2008, 4:09 pm
rate this thread
to generate self-closing tags when possible, e.g., <a name="XYZ></
a> becomes <a name="XYZ"/>. It seems that at least IE7 doesn't
like this and, as a result, highlights the following content as of it
were part of an anchor tag.
Is there some way for forcing the browser to deal with self-closing
anchors properly? Is this a known problem?
Re: self-closing tags
Bad processor. Such an operation violates the compatibility requirements
that are explicitly stated in both XML and XHTML specifications. Naughty
Of course. IE does not grok XHTML. It's a tag soup slurper that simply
ignores the "/", treating <a name="XYZ"/> as <a name="XYZ">.
Huh? The _proper_ treatment of <a name="XYZ"/> by HTML rules up to and
including HTML 4.01 is to treat it as equivalent to <a name="XYZ">/ but
practically no browser gets this right.
Anyway, it is a known problem that an <a> element with empty content
causes problems to some browsers, even when it is written in the classic
HTML style <a name="XYZ"></a> and even though such markup is valid and
conforms to HTML specifications.
So I think the cure is to refrain from generating elements with empty
content. There's almost always some other way. In fact, <a name="XYZ">
is hardly needed these days, when you can use the id="..." attribute on
the element that should be the destination anchor.
Jukka K. Korpela ("Yucca")