Multicoloured text in HTML

1o0oBhP 0 Tallied Votes 353 Views Share

Without using cascading style sheets or more complicated methods it is easy to introduce coloured text into your HTML sites/documents. This is done by using the <font> tag and its options. In addition to this the <font> tag is more backwards-compatible than most other style commands.

The way to do it is: <font color=#RRGGBB>your text here</font> where RR GG and BB are the colour componenets in hexadecimal. Try veiwing the following example

[CODE]
<html>
    <head>
        <title>Multi-Coloured Text example &copy1o0oBhP :)</title>
    </head>
    <body>
        <table>
            <tr><td><font color="#FF0000"><b>This is RED text</b></font></td><td><b><font color="#FF0000">RRGGBB = FF0000</font></b></td></tr>
            <tr><td><font color="#00FF00"><b>This is GREEN text</b></font></td><td><b><font color="#00FF00">RRGGBB = 00FF00</font></b></td></tr>
            <tr><td><font color="#0000FF"><b>This is BLUE text</b></font></td><td><b><font color="#0000FF">RRGGBB = 0000FF</font></b></td></tr>
        </table>
    </body>
</html>
[/CODE]
1o0oBhP 4 Posting Pro in Training

Hmmm, the formatting didnt come out right, even with code tags...

Dani 4,084 The Queen of DaniWeb Administrator Featured Poster Premium Member

I am still working on perfecting the engine which powers these code snippets. Not all languages are full supported, but I can assure you that I am working on it!

1o0oBhP 4 Posting Pro in Training

no worries, i thought that code tags preserved the formatting? its worked before when i have copied/pasted from devc++, i might write the html in devc++ and paste and see what happens...

1o0oBhP 4 Posting Pro in Training

Hmm it is ignoring the code tags by the look of things... dunno if that is something to check?

Dani 4,084 The Queen of DaniWeb Administrator Featured Poster Premium Member

There is no need for code tags in the Code Snippets library. The language the code is written in determines how it's formatted.

anastacia 0 Junior Poster

ACTUALLy the code for colours is in hexadecimal form but you can even put the color name
<html>
<body>
<font color="red"> this will be in red </font>
</body>
</html>
however it depends upon your browser not all browser support all colours

mmiikkee12 1 Posting Whiz in Training

<font color="crap"> makes a dingy brown...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.