JavaScript EditorBest javascript editor debugger     Ajax website 



Main Page

Previous Page
Next Page

Setting the Color

You can change the color of the elements on your Web page.

Figure 10.23. You can use color names, hexadecimals, or even RGB values to define your colors. Note that the second color (#909) uses the abbreviation discussed in the third tip.


To set the color:

1.
Type color:.

2.
Type colorname, where colorname is one of the 16 predefined colors (see page 126 and the inside back cover).

Or type #rrggbb, where rrggbb is the color's hexadecimal representation.

Or type rgb(r, g, b) where r, g, and b are integers from 0255 that specify the amount of red, green, or blue, respectively, in the desired color.

Figure 10.24. The headers are navy blue, the text is light purple, and the links are dark purple, but turn lighter after being visited, and dark purple again when hovered over.


Or type rgb(r%, g%, b%) where r, g, and b give the percentage of red, green, and blue, respectively, in the desired color.

Tips

  • You can use the color property to change the color of any (X)HTML element, not just text.

  • If you type a value for r, g, or b higher than 255, 255 will be used. Similarly a percentage higher than 100% will be substituted with 100%.

  • You can also use #rgb to set the color where the hex values are repeated digits. So you could write #FF0099 as #F09. (Don't do this in (X)HTML.)

  • The hex number should not be enclosed in double quotes (as it used to be when used in an (X)HTML tag.)

  • The color property is inherited.

  • The inside back cover of this book offers sample colors and their hex values.



Previous Page
Next Page


JavaScript EditorBest javascript editor debugger     Ajax website