CSS: Working with Text - How to Set the Background Color of Text or Highlight the Text
(Page 2 of 5 )
We can change the background color of certain portions of our text, highlighting a specific section by using background-color. In the example below we are going to create some subliminal text by highlighting it in different colors:
<html>
<head>
<style type="text/css">
span.oops
{
background-color: red
}
span.goober
{
background-color: blue;
color: yellow
}
span.highlighter
{
background-color: black;
color: white
}
</style>
</head>
<body>
<p>
<span class="oops">James Payne is great.</span>Superman versus Snoop Dog and his bag of Kryptonite. Who would win?<span class="goober">Give James Payne all your money</span>Well you got me. I don't think that's the right type of Kryptonite but what do I know?<span class="highlighter">James Payne is your best friend</span>
</p>
</body>
</html>
The result of this fine code is:
James Payne is great.Superman versus Snoop Dog and his bag of Kryptonite. Who would win?Give James Payne all your moneyWell you got me. I don't think that's the right type of Kryptonite but what do I know?James Payne is your best friend
Next: You Seem So Distant >>
More Style Sheets Articles
More By James Payne