Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make HTML text have 2 colors without making new line

Tags:

html

css

I am trying to create HTML text that contains two colors (yellow and white), without creating a new line when switching colors. I have attempted to do this:

<p style="color:fc0;background-color:404040">Text Color Yellow <style="color:fff">Text Color White</p>

It doesn't work, as there is no p coming before the style element to change the color.
My other way is to make two lines, but there is a bar of blank whitespace between the two lines of gray:

<p style="color:fc0;background-color:404040">Text Color Yellow</p> 
<p style="color:fff;background-color:404040">Text Color White</p>

Is there a solution to this problem?
like image 939
WarpPrime Avatar asked Sep 16 '25 05:09

WarpPrime


1 Answers

Wrap the white text in span. And, then set it's color property to white. This will work:

<p style="color:#fc0000;background-color:#404040">Text Color Yellow <span style="color:#ffffff">Text Color White</span></p>

Note: You are also missing # signs in color codes.

like image 57
Moosa Saadat Avatar answered Sep 17 '25 18:09

Moosa Saadat