Changing a links underline opacity


Recently I needed to style the underline of a bunch of links, but then I also had to respect the original color of the link and the background.

I found this neat solution using text-decoration-color & color-mix by mixing the currentColor with transparent.

css
a {
  text-decoration-color: color-mix(in lch, currentColor 30%, transparent);
}

We can mix the currentColor with transparent to get a transparent line that respects the links color!

Example