Home >Web Front-end >CSS Tutorial >Can I Change the Color of an Underline in Text?

Can I Change the Color of an Underline in Text?

Susan Sarandon
Susan SarandonOriginal
2024-11-04 00:57:30845browse

Can I Change the Color of an Underline in Text?

Customize Text Underline Color

Q: Is it possible to alter the color of the line drawn under a text?

A: Yes, you can now effortlessly change the underline color using CSS.

For Modern Browsers (text-decoration-color support):

To specify the underline color, use the following rule:

<code class="css">text-decoration-color: #color_value;</code>

For example, to create red text with a blue underline, the code would be:

<code class="css">text-decoration-color: blue;</code>

For Older Browsers (border-bottom method):

If your browser does not support text-decoration-color, an alternative method involves creating a border underneath the text:

<code class="css">a:link {
  color: red;
  text-decoration: none;
  border-bottom: 1px solid blue;
}

a:hover {
  border-bottom-color: green;
}</code>

In this example, it creates a blue underlined link that turns green on hover.

The above is the detailed content of Can I Change the Color of an Underline in Text?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn