Often times people will use border-bottom: 1px solid in favor of text-decoration: underline to give their links some breathing room. But what if you're giving it too much breathing room and want to adjust the height of that underline. With Adobe Garamond that happened to be the case, so we've come up with this little css trick:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
a {
  display: inline-block;
  position: relative;
}
a::after {
  content: '';
  position: absolute;
  left: 0;
  display: inline-block;
  height: 1em;
  width: 100%;
  border-bottom: 1px solid;
  margin-top: 5px;
}

This overlays a CSS pseudo element with a border-bottom that can be adjusted by changing margin-top.

For handling browsers that don't support pseudo elements I recommend targeting them with the Paul Irish class-on-html-trick.

Let your links breathe!

Categories: css, design


Comments