Do you chose effective anchor names?

Last updated by Tiago Araújo [SSW] 4 months ago.See history

These are the things you should consider when creating an anchor link:

  1. Make it meaningful - When you define anchors names, use meaningful names. When you are sending the URL by email it helps indicate what you are talking about. Avoid list numbers, as they often change. An anchor like "#13" becomes incorrect when the order changes.
  2. Know they are case sensitive - Are and the same? The answer is "no" because they might be not case sensitive when they test in some browsers.
  3. Don't add spacing - When you are defining an anchor name, make sure there are no spaces within the name
<a name="Some Anchor Name">

Bad example - Spaces within anchor name

<a name="SomeAnchorName">

Good example - No spaces within anchor name

  1. Don't define names starting with a # - This is a common mistake because the # is used on the "href"

When you are defining an anchor name you do not use a hashtag.
Bear in mind that when you are referencing an anchor you do use a hashtag.

<a name="#SomeAnchorName">

Bad example - Hashtag on anchor name

<a name="SomeAnchorName">

Good example - No hashtag on anchor name

We have a program called SSW Code Auditor to check for #3 and #4 on this rule.

We open source. Powered by GitHub