View Full Version : Single words in different colours


MrB
02-28-2013, 11:02 AM
Please can anyone give me some simple HTML code to put individual words in the same paragreaph in different colours? e.g. If I wanted to write 'Richard Of York Gave Battle In Vain' in red, orange, yellow, green, blue, violet, indigo respectively, how would I go about it?

Many thanks (again!) for your advice.

Doitsu
02-28-2013, 12:13 PM
IMHO, the easiest way to achieve this is to define span styles for each color and assign them to each word.
For example, add the following styles to the style section of the .html file or the stylesheet:

<style type="text/css">

span.red { color: red; }
span.blue { color: blue; }

</style>

and the following code in the .html file:

<p>This is a <span class="red">red word</span> and this a <span class="blue">blue one</span>.</p>

For more information, see this website (http://www.w3schools.com/css/default.asp).

theducks
02-28-2013, 12:17 PM
<p><span style="color: red;">Red</span><span style="color: green;">Green</span><span style="color: blue;">Blue</span><span style="color: yellow;">Yellow</span></p>

You can use the names :
black
silver
gray
white
maroon
red
purple
fuchsia #FF00FF
green
lime
olive
yellow
navy
blue
teal
aqua

for any other shade, you will need to code the RGB values

MrB
02-28-2013, 12:57 PM
Thank you both for your suggestions.