Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Underline color

I have this code here:

echo "<u><font color='red'><br>$username</font></u>"; 

Firstly, as you can see, it's underlined (< u >). Second, all text is all red. Well is there anyway to leave the text ($username) red but the underline black?

like image 355
user1641508 Avatar asked Sep 24 '12 01:09

user1641508


People also ask

How do you change the color of an underline 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.

Can you change the color of an underline in Word for Mac?

Click on the Modify button. There will be a Format dropdown menu at the bottom left; click it to unfold and choose Font. Change Underline color to Automatic (this will make underlines match the color of the font)

Can I change the underline color in preview?

Tap Annotate on the toolbar. Select the Highlight , Underline , or Strikeout tool. You can select the color for each tool by tapping the color picker .


1 Answers

There's now a new css3 property for this: text-decoration-color

So you can now have text in one color and a text-decoration underline - in a different color... without needing an extra 'wrap' element

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>

Codepen

NB:

1) Browser Support is limited at the moment to Firefox and Chrome (fully supported as of V57) and Safari

2) You could also use the text-decoration shorthand property which looks like this:

<text-decoration-line> || <text-decoration-style> || <text-decoration-color> 

...so using the text-decoration shorthand - the example above would simply be:

p {   text-decoration: underline red; } 

p {    text-decoration: underline red;  }
<p>black text with red underline in one element - no wrapper elements here!</p>
like image 79
Danield Avatar answered Oct 04 '22 02:10

Danield