There are 216 different colors that are considered web safe. The best way to make sure you are getting a web safe color is to remember these: 00, 33, 66, 99, cc, ff
Those are HEXADECIMAL (base 16) numbers for 0, 51, 102, 153, 204 and 255
You don't really need to know anything about hexadecimal numbers if you just remember those six combinations, 00, 33, 66, 99, cc and ff
Computer colors are some combination of RED, GREEN and BLUE (or RGB) - two digits each - RRGGBB. To get black, you need 0 red, 0 green and 0 blue. To get white, you need 255 (the highest number) red, 255 green and 255 blue.
There are 255 shades of each color. In hex, 255 is ff. So to show black in Hex you would use the RGB combination of 000000 (00 red, 00 green and 00 blue) and to show white, you would use the RGB combination of ffffff (ff red, ff green and ff blue). All other colors fall somewhere between those two combinations.
To make it a bit simpler - red is all red, no green or blue - ff0000.
So using just ff and 00, green is 00ff00 and blue is 0000ff
Now we'll use them to color our text using the
<span>...</span> tag and the color property. You will use the <span> tag when you want to add a style to a portion of your paragraph or line. This is called an inline tag. You can also add your style to almost any other tag; <em style="color:#00f;">This italicized text would be blue</em>
For simplicity, in most of the lessons when a new style is introduced, it will be shown using a <span> tag.
To make your text come out red, use
<span style="color:#ff0000;">And your text will be red
</span> (Don't forget the closing span tag!).
The color number has to be preceeded by a pound sign: # which tells the browser to read a hex number.
Tip: When using web-safe colors, you can shorten the code to one digit each for red, green and blue:
#rgb or <span style="color:#f00;">This would be red</span> or #0f0, #00f, #cc0, etc.
- Try posting something in a color and in Lesson 5 I'll show you another shortcut!
- If you are a DelphiPlus member using the WYSIWYG editor, you need to click SOURCE before typing in any code.
- If you are a DelphiAdvanced member, check the box at the bottom of the input window that says "Check here if HTML tags are in the message"
- If you are a DelphiBasic (free) member, you will need to upgrade to be able to use HTML in your messages.
- You can post your homework or ask questions about this lesson as a reply to this message.