self-closing tags
I'm generating HTML using XSLT. It seems that the XSLT processor wants
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?
TIA,
David
Re: self-closing tags
Scripsit David Schwartz:
> I'm generating HTML using XSLT. It seems that the XSLT processor wants
> to generate self-closing tags when possible, e.g., <a name="XYZ></
> a> becomes <a name="XYZ"/>.
Bad processor. Such an operation violates the compatibility requirements
that are explicitly stated in both XML and XHTML specifications. Naughty
processor.
> 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.
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">.
> Is there some way for forcing the browser to deal with self-closing
> anchors properly? Is this a known problem?
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")
http://www.cs.tut.fi/~jkorpela/
Re: self-closing tags
>
> 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.
>
But that would require javascript, right?
David
Re: self-closing tags
On Apr 22, 5:31=A0pm, David Schwartz <david... [at] gmail.com> wrote:
> > 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=3D"XYZ">=
> > is hardly needed these days, when you can use the id=3D"..." attribute o=
n
> > the element that should be the destination anchor.
>
> But that would require javascript, right?
Not at all.
<a href=3D"#foo">link</a> will link to <h2 id=3D"foo">heading</h2> in just
about any browser in use today. No JavaScript involved at all.
Steve
Re: self-closing tags
>
> link will link to <h2 id="foo">heading</h2> in just
> about any browser in use today. No JavaScript involved at all.
Cool! Works great! Thanks so much.