Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS text-decoration underline color [duplicate]

Possible Duplicate:
Changing Underline color

It's possible to change only line color which is under text? I would like to see something like red letters with a blue line below it, but I can't find out how to get this done.

like image 259
Wizard Avatar asked Oct 09 '12 16:10

Wizard


People also ask

How do I color underline text in CSS?

Underline tag: To change the color of the underline, we need to add some styling using CSS (inline/internal/external). By default, the color of the underline is black. In CSS, we will use text-decoration property to style underline.

How do I change the color of a line in CSS?

The text-decoration-color property sets the color of the underline, overline, or line-through on text with the text-decoration property applied. It can also set the underline color on links.

How do you customize underline in CSS?

Steps: Create background image with linear-gradient() . Adjust its size with css background-size property. Place it at the bottom left position of the element with background-position css property.


2 Answers

You can do it if you wrap your text into a span like:

a {    color: red;    text-decoration: underline;  }  span {    color: blue;    text-decoration: none;  }
<a href="#">    <span>Text</span>  </a>
like image 163
Cherusker Avatar answered Sep 23 '22 16:09

Cherusker


(for fellow googlers, copied from duplicate question) This answer is outdated since text-decoration-color is now supported by most modern browsers.

You can do this via the following CSS rule as an example:

text-decoration-color:green


If this rule isn't supported by an older browser, you can use the following solution:

Setting your word with a border-bottom:

a:link {   color: red;   text-decoration: none;   border-bottom: 1px solid blue; } a:hover {  border-bottom-color: green; } 
like image 25
Rob Avatar answered Sep 19 '22 16:09

Rob