To change more options about the text, you must use the
style attribute within a heading or paragraph tag. This tag allows you to specify the size, color, and other attributes of the text in your document.
<p style="color:color code
">...</p>size is in pixels without a space. color code is a code specifying the text color.
<html> <head> <title>My Web Page</title> </head> <body> <p style="color:#00ff00">This text appears in green.</p></p> <p style="color:#0000ff;font-family:arial">This text appears in blue and arial font.</p></p> <p style="color:#ff0000;font-family:georgia;font-size:20px">This text appears in red, georgia font, and size 20 pixels.</p></p> </body> </html>
In Example 1, the text inside the first
<p> tag is set to the color #00ff00, which is a code for green. Note: When closing a tag, do not ever include anything more than just the tag. Continue to learn more about how to use color codes.
Understanding Color Codes
Color codes are always composed of six Hexadecimal (uses digits from 0-F, like 0, 1, 2… 9, A, B, C, D, E, F) digits. The first two digits specify how much red should be included in the color mix.
00 would be no red, and
FF means the brightest possible red in the mixture. The next two digits specify how much green is in the mixture, and the last two digits specify how much blue enters in the mix.
Simple colors are easy to make. For example, the brightest green would be
#00FF00 (no red, all green, no blue). A bright blue would be
#0000FF (no red or green, strong blue).
Colors can also be made darker by reducing the amount of color. To make a dark red, use the code
#990000. It includes only about half of the regular brightness of red. Similarly, a dark blue would be produced by the code
As you probably already guessed, the primary colors can be mixed to produce secondary colors. Mixing colors takes place using the rules of light color, not paint color. The primary colors of light are red, green and blue (not red, yellow and blue).
|Light Color Mixing|
|Mix these…||Get this…|
|Red and Green||Yellow|
|Red and Blue||Purple|
|Green and Blue||Turquoise|
|Red, Green and Blue||White|
HTML Color Chart
Mixing other combinations and varying the brightness of each of the three primary colors produces a wide range of colors. The following chart shows how colors may be mixed and lists the code for each mixture for your reference.
|Red, Green and Blue|
|Red and Green Combinations|
|Red and Blue Combinations|
|Green and Blue Combinations|
Spend some time understanding how the above colors were created. You should see a connection between the hexadecimal digit combinations and the actual color produced. Now, without looking at the chart, try to guess what code was used for the following colors.
You have already learned how to change the color of the text. Now, let’s look at how to change the background color of your web page. On simple web pages, only one color may be used for the whole background. It can be specified as part of the
<body> tag. Here is the syntax (proper way to use it) of the
<body style="background-color:#color code
">...</body>color code is a code specifying the text color.
HTML also has 17 standard color names that may be used by simply using their names. These are:
There are other colors that are named. A list can be found here.