100 likes | 277 Vues
This guide explores how to control colors in HTML elements, including text, backgrounds, and tables. Learn to set page backgrounds and text colors using both English notation with predefined colors and hexadecimal notation, which allows for more than 2 million shades. This guide includes examples, hexadecimal values (e.g., #FF0000 for red), and a brief overview of decimal and hexadecimal systems. Enhance your web design skills by mastering the use of colors in HTML!
E N D
Color of HTML Elements • You can control the color of the following elements: • All text within the body of a page • Background of a page • Background of a table • Each row of a table • Each cell of a table
Examples • To set • Page background color to black and • text color to white. <body bgcolor=“white” text=“black"> • To set • Particular text to blue <font color=“red">This part of the sentence is shown in red</font>, while the rest is in the default color.
How To Specify Color • Color may be specified • in English notation with predefined color names(for 16 colors), or • in a format known as the Hexadecimal notation
Specifying Colors in Hex Notation • Using hexadecimal notation, it is possible to specify over 2 million shades • #FF0000--red • #00FF00--green • #0000FF--blue • #FFFF00—yellow • Other examples • To set some text to “brown” color: <font color=“#FF8429”>some text</font>
Decimal Notation • In Decimal System • Ten symbols are usedto express any number-- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. • Each position implies a power of 10 • E.g.(Decimal) number 3234 means (3 x 103) + (2 x 102) + (3 x 101) + (4 x 100)= 3000 + 200 + 30 + 4= 3234
Hexadecimal Notation • In Hexadecimal System • 16 symbols are used--0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. • Each position implies a power of 16 • E.g.,(Hexadecimal) number 5F means(5 x 161) + (15 x 160)= (5 x 16) + (15 x 1)= 80 + 15 = 95 (decimal)
RGB Values • #rrggbb-- e.g., #FFFF00 • rr -- These 2 digits indicate intensity of red • gg --These 2 digits indicate intensity of green • bb -- These 2 digits indicate intensity of blue • For example, • #FF0000--red • #00FF00--green • #0000FF--blue • #FFFF00—yellow • Other examples
Your Turn • Given a hex number: A5 • What is its decimal equivalence? • Given a hex number: 120 • What is its decimal equivalence? • Given a decimal number: 21 • What is its decimal equivalence? • Given a decimal number: 256 • What is its decimal equivalence?