Named anchor (A) with NAME is similar to conflict with DIV ID

I am on a site that uses a hash listener to show and hide DIV content and scroll to a named anchor with the same name.

I had a weird problem where instead of scrolling to an anchor, it would scroll to a DIV with an identifier the same as the binding name.

As soon as I changed the DIV ID to something else, the behavior was as expected.

I cannot find any documentation on this and am wondering if this is documented behavior.

Code that works:

<a name="top">top</a>

<p id="bottomx" style="height: 1800px;">
<a href="#top">top</a>
<a href="#bottom">bottom</a>
<br>
</p>
<a name="bottom">bottom</a>

Doesn't work as expected:

<a name="top">top</a>

<p id="bottom" style="height: 1800px;">
<a href="#top">top</a>
<a href="#bottom">bottom</a>
<br>
</p>
<a name="bottom">bottom</a>

P "bottom". , DIV "bottom", page.html # bottom, DIV.

. , ? Safari FF.

+5
2

id name:

HTML ( HTML MIME) , , .

  • URL-, fragid URL.

  • fragid - , ; .

  • fragid , UTF-8 Unicode , UTF-8. - UTF-8 (, ), .

  • , DOM , , , - ; .

  • DOM , , fragid ( fragid), ; .

  • fragid ASCII- , ; .

  • .

+7

HTML 4.01 XHTML 1.0 , name a id, , , . , .

HTML5 , name a .

( ) id , id , <a name=...> id HTML , id, . , , .

+1

All Articles