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

How Can I Change the Color of the Underline Beneath Text?

Mary-Kate Olsen
Release: 2024-11-03 19:37:29
Original
981 people have browsed it

How Can I Change the Color of the Underline Beneath Text?

Modifying Text Underline Color

Changing the color of the underline beneath text can be achieved using certain CSS properties.

Option 1: text-decoration-color (Modern Browsers)

For modern browsers that support the text-decoration-color property, you can set a color directly, as follows:

<code class="css">text-decoration-color: green;</code>
Copy after login

Option 2: border-bottom for Older Browsers

If the text-decoration-color property is not supported, you can use a workaround involving a border on the bottom edge of the text:

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

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

This method allows you to create a colored line beneath the text, simulating the effect of an underline.

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

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template