Archive for the ‘HTML’ Category

19
Oct

Linking to HTML Elements via id Attribute

My coworker Brian Hall and I came across a posting saying “everyone knows this”, and the this was that you can use a hash to link to an id.  Here’s a snippet to demonstrate:

My Page With Internal Links

Navigation

A

Some content here that if relevant to 'A'

B

Some content here that is relevant to 'B'

C

Some content here that is relevant to 'C'

Previously, the way you would do this is to use an a tag with a name value around the h2 elements:

My Page With Internal Links Using Name Attribute

Navigation

A

Some content here that if relevant to 'A'

B

Some content here that is relevant to 'B'

C

Some content here that is relevant to 'C'

The “everyone knows this” technique has many advantages: