Add anchors to your section titles

It’s really good UX practise to add anchors for your section titles. It helps users to link to a part of article. You can see a good example of this in README files on Github. Here’s a sample.

Usualy we link <a> tag to an element using id attribute but this isn’t supported by ASP websites. Instead of using id, we can use name attribute:

1
<a name="about" href="#about">About</a>

It’s a link which points to itself. It’s a section title so you also should wrap it in an h2 or h3 tag.

Optionaly we can add some style for anchor links:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[href^="#"] {
position: relative;
color: inherit;
}
[href^="#"]:hover {
color: #e14a42;
}
[href^="#"]:hover:before {
content: '#';
right: 100%;
position: absolute;
margin-right: .2em;
}

Check out demo page.