Dani Springer Dani Springer - 1 year ago 111
HTML Question

#top Works By Itself

I added this:

<a href="#top">text</a>
to my website.

I clicked on it without adding
anywhere, and it worked.

How come?

Answer Source

This is built into HTML5 according to the spec:

If target is the top of the document, then scroll to the beginning of the document for the Document

In other words, it's a special case and you don't need to specify an ID for the top of the page.

See also MDN:

Note: You can use the special fragment "top" to create a link back to the top of the page; for example <a href="#top">Return to top</a>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download