Colored link underline (cross-browser compatible)

Far far away, behind the word mountains, far from the countries Vokalia and Consonantia , there live the blind texts. Separated they live in Bookmarksgrove right at the coast of the Semantics, a large language ocean. A small river named Duden flows by their place and supplies it with the necessary regelialia.


The colored underline is done with a pretty easy solution – it’s basically just a background-image .

  1. Create an SVG which is 1px × 2000px (or whatever fits your needs) 1
  2. Convert this image to base64 2
  3. Add styling for the link (see below)

1 I did this with background-repeat and background-position only because like this it's also possible to add an icon with :before . It would also be possible to do this with a 1px × 1px image and then simply use background-repeat: repeat-x;

Here's the code of the SVG, you can simply copy/paste/edit it (e.g. adjust the color and/or size):

<svg xmlns="http://www.w3.org/2000/svg" width="2000" height="1">
  <rect fill="#73c92d" width="2000" height="1"/>
</svg>
  

2 I used our Gulp workflow for that, but you can easily do this with free online tools, too:

  1. Save your image as SVG
  2. Open the SVG file in a text editor
  3. Copy the code
  4. Use a tool such as base64encode.org to encode the image to a Base64 value
  5. Set the background image like this:
    background-image: url(data:image/svg+xml;base64,YOURBASE64CODEHERE);