Home > Article > Web Front-end > How can I change the underline color of text in PHP without changing the text color?
Using CSS to Change Underline Color
Question:
In PHP code, a string is currently displayed with red text and a red underline. The goal is to keep the text red but change the underline to black.
Answer:
Utilizing CSS3's new property, text-decoration-color, allows you to achieve this desired effect. This property enables you to specify a different color for the text decoration, such as the underline, without wrapping the text in an additional element.
Example:
p { text-decoration: underline; -webkit-text-decoration-color: red; /* Safari still uses vendor prefix */ text-decoration-color: red; }
<p>black text with red underline in one element - no wrapper elements here!</p>
By adding this CSS code to your document, the text within the
tags will remain red, while the underline will now be displayed in red, giving you the desired visual effect.
The above is the detailed content of How can I change the underline color of text in PHP without changing the text color?. For more information, please follow other related articles on the PHP Chinese website!