HTML colors

HTML colors
 
HTML colors
  • Currently 4 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Rating: 4/5 (1 votes cast)

Thank you for rating!

You have already rated this page, you can only rate it once!

Your rating has been changed, thanks for rating!

Log in or create a user account to rate this page.


There are three ways to set colors on a web page: the first uses color designations in hexadecimals, the second - in decimal, and the third - uses names of certain colors. The most used is the method based on hexadecimals, because it's the most universal. The decimal system, although it's the easiest to understand, is used only with CSS.

Hexadecimal colors

To set colors in HTML the hexadecimal code is used. The hexadecimal system in contrast to decimal, is based, as its name implies, on the number 16. The numbers are as follows: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. The numbers from 10 to 15 are replaced by Latin letters. Table 1 shows the corresponding decimal numbers and hexadecimal numbers.

Table 1. Decimal and hexadecimal numbers, less than 16.

Decimal

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Hexadecimal

1

2

3

4

5

6

7

8

9

A

B

C

D

E

F

Numbers greater than 15 in hexadecimal are formed by joining two numbers into one. For example, the number 255 in decimal number system corresponds to FF in hexadecimal system (table 2).

Table 2. Decimal and hexadecimal numbers, greater than 16.

Decimal

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

Hexadecimal

10

11

12

13

14

15

16

17

18

19

1A

1B

1C

1D

1E

1F

To avoid confusion in defining the system in use, before hexadecimal numbers you'll see the pound sign #, as follows #666999.

An example of a typical color used in HTML, as follows.

<body bgcolor="#FA8E47">

The background color is set to #FA8E47. The pound sign # before the numbers means that it's hexadecimal. The first two digits (FA) indicate the red color, the digits from third to fourth (8E) indicate - green, and the last two digits (47) - blue. As a result we get this color.

colors

Each of the three colors - red, green and blue - can range from 00 to FF, as a result this forms 256 shades for each of the basic colors. Thus, the number of RGB colors can be 256 x 256 x 256 = 16.777.216 combinations.

Web colors

If you set the color depth of the monitor to 8-bits (256 colors), then the same color can be displayed in a different way depending on the browser you are using. This is due to a different method of displaying graphics, the browser works with its own palette and can not display the color that it is not in it. In that case, the color is replaced by a combination of other colors, which when combined would resemble it. In order for a color to stay the same in different browsers, a palette was introduced, so-called web colors. These are the web colors - with every component (red, green and blue) having six values - 0 (00), 51 (33), 102 (66), 153 (99), 204 (CC), 255 (FF). In the parentheses is the hexadecimal value of the components. The total number of colors from all possible combinations gives 6x6x6 - 216 colors. An example of a web color - #33FF66.

The main advantage of the web color is that it is displayed the same in all browsers. At the moment, the relevance of web colors is of little significant due higher quality of monitors and their empowerment.

Color names

Instead of memorizing the combinations of numbers, you can use well-known names of colors.

<body bgcolor="navy">

The table below contains the names of 16 basic colors used in all browsers.

Name

Color

Hex

Red (R)

Green (G)

Blue (B)

aqua

aqua

#00FFFF

00

255

255

black

black

#000000

00

00

00

blue

blue

#0000FF

00

00

255

fuchsia

fuchsia

#FF00FF

255

00

255

gray

gray

#808080

128

128

128

green

green

#008000

00

128

00

lime

lime

#00FF00

00

255

00

maroon

maroon

#800000

128

00

00

navy

navy

#008000

00

00

128

olive

olive

#808000

128

128

00

purple

purple

#800080

128

00

128

red

red

#FF0000

255

00

00

silver

silver

#C0C0C0

192

192

192

teal

teal

#008080

00

128

128

white

white

#FFFFFF

255

255

255

yellow

yellow

#FFFF00

255

255

00


 

Read also

CSS: working with color

CSS: working with color

Details about "float" property

Details about "float" property

Post comment

basicuse.net
html5_css
106160485398655174790

Quick navigation

General navigation