anchor names from headers (Setext and atx)?

Michel Fortin michel.fortin at
Mon Sep 24 14:07:06 EDT 2007

Le 2007-09-22 à 14:22, Jeremy C. Reed a écrit :

> <a name="This is an H2"/>

Be careful with that. The `/>` terminator is only recognised by
browsers when using the XML parser, which is to say when you send
your document with an XML mime type (text/xml, application/xml,
application/xhtml+xml). For the HTML parser (text/html), the markup
above will be an unclosed anchor tag, and will span until the next
opening anchor tag unless a corresponding closing tag (`</a>`) is found.

If your anchor is not a link, there will be few side effects beside a
strange DOM tree inside the browser. That's unless you have some CSS
rule defined for tag "a". For an example of this: go to the [Markdown
project page][1] on Daring Fireball, move your mouse pointer over the
first words in the paragraphs following the "Discussion List" and
"Installation and Requirements" headers and you'll see some
unexpected rollover effects.


The correct way to write an anchor (so that it can be read by HTML
parsers) is to close it with an explicit closing tag:

<a name="anchor-name"></a>

Michel Fortin
michel.fortin at

More information about the Markdown-Discuss mailing list