Page 48 - DCAP408_WEB_PROGRAMMING
P. 48

Web Programming




                    Notes          2.1.10  Colors

                                   The attribute changing the color is color. It’s values can be color names like red, green, blue, etc.
                                          <span  style=”color:red”>red  text</span>
                                   However, only 16 color names are supported by the W3C HTML 4.0 standard (aqua, black, blue,
                                   fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow). For
                                   all other colors you must specify how the color is made up from the three base colors red, green
                                   and blue (RGB).



                                     Did u know?  What you need to specify for all three base colors?
                                     You  need to specify for all three base colors an intensity  between 0 (lowest) and  255
                                     (highest), giving you the color that results from mixing these base colors with the specified
                                     intensities.
                                   For example, assigning 0 to red, 0 to green and 255 to blue gives you “100% blue”. There are two
                                   ways of defining RGB  values – firstly using  hexadecimal notation, secondly using  decimal
                                   numbers.
                                   When defining the RGB values of a color in hexadecimal notation, you write a “#” followed by
                                   six digits, of which two represent the red value, two the green value and two the blue value.
                                   These are in hexadecimal notation, i.e. the lowest value 0 is written as “00”, the highest value 255
                                   is written as “FF”, for example, “#0000FF”.
                                   When using the decimal numbers, you write “rgb”, followed by a triplet of numbers, in parentheses
                                   and separated by commas, for example “rgb(0,0,255)”.

                                   This table shows the result of combining red, green and blue in various ways:
                                   Color  Color  HEX  Color  RGB
                                   #000000    rgb(0,0,0)
                                   #FF0000  rgb(255,0,0)
                                   #00FF00  rgb(0,255,0)
                                   #0000FF  rgb(0,0,255)
                                   #FFFF00  rgb(255,255,0)
                                   #00FFFF  rgb(0,255,255)
                                   #FF00FF  rgb(255,0,255)
                                   #C0C0C0  rgb(192,192,192)
                                   #FFFFFF  rgb(255,255,255)
                                   <p  style=”color:#FF00FF”>WOW!  This  is  pink</p>
                                   <p  style=”color:rgb(255,0,255)”>This  is  pink,  too!</p>


                                          Example:
                                   <html>
                                   <body>
                                   <h1  style="font-family:verdana;">A  heading</h1>

                                   <p  style="font-family:arial;color:red;font-size:20px;">A  paragraph.</p>
                                   </body>
                                   </html>


          42                                LOVELY PROFESSIONAL UNIVERSITY
   43   44   45   46   47   48   49   50   51   52   53