Secret ingredients to quality software


Do you chose efficient anchor names?

Last updated by Tiago Araujo on 02 Mar 2017 09:48 pm (over 4 years ago) See History

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

  1. Meaningful - When you use named anchors in a web page, use meaningful names. When you are sending the URL by email it helps indicate what you are talking about, and in addition, list numbers often change. An anchor like "#13" becomes incorrect when the order changes.
  2. Case sensitive - Are "" and "" the same? The answer is "no" because they might be not case sensitive when they test in some browsers.
  3. No spacing - When you are defining an anchor name, make sure there are no spaces within the name.

Bad: <a name="Some Anchor Name">

Good: <a name="SomeAnchorName">

  1. Don't start with a # - When you are defining an anchor name you DO NOT use a #. When you are referencing an anchor you DO use a #. This is a common mistake because the # is used on the "href".

Bad: <a name="#SomeAnchorName">

Good: <a name="SomeAnchorName">

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

Adam CoganAdam Cogan

We open source. This page is on GitHub