Thursday, 12 March 2015

SPECIFYING COLORS WITH CSS

Needless to say, there are ways to specify color on a page using cascading style sheets. First, let’s look at how colors are specified using CSS. The two methods available in HTML are also available in CSS. You can specify colors by name or by using a six – digits hexadecimal specification. There are some other options as well. You can specify colors using a three digit hexadecimal number, which is shorthand for cases where both digits in each pair are the same. For example, if the color you’re using is #fffff (white), you can just specify it as # fff. Or, if you want a light blue such as #66ccff, you can specify it as #6CF.

 You can also specify colors using decimal values or percentages. For example, #66CCFF can be specified as (102,204, 255) using decimal notation. Or, fi you prefer, using percentages, like this: (40%, 80%, 100%). If you don’t’ want to worry about these alternative methods, that’s fine. You can just use the same ones that you use when specifying colors in HTML.

SPOT COLOR

When you change a page’s text colors by using attributes to the <body> tag, that change affects all the text on the page. Spot color is the ability to change the color of individual characters on your page, which you can use instead of or in addition to a global text color.

FIGURE 7.30 background and text colors.














In yesterday’s lesson you learned about using the HTML tag <font> for setting the font size and font name. a third attribute to <font>, color, enables you to change the color of individual words or phrases. The value of color is either a color name or number:

<p> when we go out tonight, we’re going to paint the town

<font color =” #ff0000”>RED</font>

Of course, you can use font sport colors in addition to font names and sizes.

CHANGING TEXT COLORS

It wouldn’t make much sense to change the background color of a page if you couldn’t change the text colors as well. Just as you can use the bgcolor attribute of the <body> tag to change a page’s background color, there are attributes that enable you to modify text colors on a page.

Text colors are specified with the same identifiers as background colors. The following attributes can be added to the <body> tag of a page to alter the color of the pae text and link colors:

Text

Controls the color of all the opal’s body text except for link text, including headings, body text, text inside tables, and so on.

Link

Controls the color of link text for links that the user has not already clicked on.

V link

Controls the color of links that the user has already visited

A link  

Controls the color of a link while the user is clicking on it. When th user clicks on a link, it changes to the color, when he or she releases the mouse button, it switches back.

Remember the haunted house image that you inserted on a page earlier? The page would be decidedly spookier with a black background, and orange text would be so much more appropriate for the holiday. To create a page with a black background, orange text, and deep red unvisited links, you might use the following <body> tag:

CHANGING BACKGROUND COLOR OF A PAGE.

To change a page’s background color decide what color you want and then add the bgcolor attribute to the<body> tag .the <body> tag, in case you’ve forgotten, is the tag that surrounds all the content of your HTML file. <head> contains the title, and <body> contains almost averting else. Bgcolor is an HTML extension introduced by Netscape in the 1.1 version of the browser and incorporated into HTML 3.2.

To use color numbers for backgrounds, you enter the value of the bgcolor attribute of the <body> tag (the hexadecimal number you found in the preceding section) in quotation marks. They look like the following:

<body bgcolor = “#ffffff”>
<body bgcolor=”#934c8”>

To use color names, simply use the name of the color as the value to bgcolor:

<body bgcolor =”white”>
<body bgcolor=”green”>

NOTE

Some browsers enable you to indicate color numbers without the leading hash sign (#). Although this method might seem more convenient, it’s incompatible with many other browsers.

USING COLOR

  As you’ve seen, one way to add a splash of color to the black, gray, and white on your web pages is to ad images. However, several HTML attributes enable you to change the colors of the page itself, including changing the background color, changing the color of the text and links, and adding spot color to individual characters.

In this section, you’ll learn how to make all these changes in HTML 3.2.however,as is the case with most of the presentational attributes we’ve covered thus far, color attributes are deprecated in HTML 4.01 in favor of style sheets. You’ll learn more about the style sheet approach in lesson 9.

SPECIFYING COLORS

Before you can change the color of any part of an HTML page, you have to know what color you’re going to change it to. You can specify colors using the color extensions to HTML in two ways:
·         Using a hexadecimal number representing that color

·         Using one of set of predefined color names.

The most flexible and widely supported method of specifying a color is to use the numeric identifier. Most image – editing programs have what’s called a color picker – a tool for choosing a single color from a range of available colors. Some color pickers display the value of that color in RGB form as three numbers representing the intensity of red, green, and blue in that color, Each number is usually 0 to 255, with 0 0 0 being black and 255 255 255 being white. If you use one of these tools, you’ll have to convert the decimal numbers to hexadecimal. These days, most tools with color bickers also provide the hexadecimal values for red, green, and blue, which is what web browsers require. In fact, the color picker that’s built into the Mac OS includes the hexadecimal values to make things easy on web publishers.

The final hex number you need is all three numbers put together with a hash sign (#) at the beginning, as in the following.