Search code examples
htmlcssanchor

Underlining an html anchor with different color


Is it possible to underline an anchor tag with a color other than its text color? Any example will be appreciated.

EDIT: Is it possible to specify color as hex e.g. #8f867c ?


Solution

  • You cannot specify the underline color separately, but you can use a little trick:

    a {
        color: red;
        text-decoration: none;
        border-bottom: 1px solid green;
    }
    

    Note that the border will not appear exactly where the underline would have appeared, sorry.