Write an HTML script which displays the web page having some specific background color.
solution:
XHTML Document[Bgcolor.html]
<html xmlns="http://www.learnhtmeasyl.blogspot.com/2017/xhtml">
<html>
<head>
<title>coloring the background</title>
</head>
<body bgcolor="#FFFF00">
<h3>This is document has colored background</h3>
</body>
</html>
In above document we have specified background color using the bgcolor attribute.
The color can be specified by either using the color name in double quotes or using the hex code as given in the above document.The first two digits of Hex code represents the red value then next two digits specify the green value and final two digits specify the blue value.Hence the corresponding output will be as follows.
Note that the background color is specified by the hexadecimal value.Following table shows the hex and corresponding decimal values.
Decimal value-Hexadecimal value
1 - 1
2 - 2
3 - 3
4 - 4
5 - 5
6 - 6
7 - 7
8 - 8
9 - 9
10 - A
11 - B
12 - C
13 - D
14 - E
15 - F
In HTML,the colors are specified by begining with # and the FF denotes 255.In this color code first two digits specify the amount of red color then next two digits specify the green color and the last two digits specify blue color.
#FF 00 00
↓
red color
Hence is used to set the background color red.Each pair of digits specifies 0 to 255 color values.Thus hexadecimal color coding helps us to specify.
256*256*256=16777216 colors.
The color can also be specified by its name as follows.
<html>
<body bgcolor=yellow>
</html>
No comments:
Post a Comment