Page 69 - Code & Click - 7
P. 69
Color Property
The Color property is used to specify the colour of text for various text elements in a web page. You
can specify a recognised colour name, a hexadecimal colour value, or a RGB colour value.
• Recognised colour names include red, green, yellow, pink, cyan, etc.
For example,
color: yellow
• Hexadecimal colour values are specified as #RRGGBB, where RR (red), GG (green), and BB
(blue) are components of the colour and have values between 0 and FF.
For example,
color: #FF00FF
• RGB colour values are specified as rgb (red, green, blue), where each colour value can be from
0 to 255 or a percentage from 0 to 100.
For example,
color: rgb(111, 55, 165)
color: rgb(50%, 100%, 25%)
Consider the code given below:
<style type = ‘‘text/css’’>
p {color: #FF0000}
h1 {color: orange}
</style>
The above code specifies to the browser that the paragraph text is in red colour and heading level
one is in orange colour.
Hexadecimal Values of some common colours
Colour Hexadecimal Value Colour Hexadecimal Value
Black #000000 Blue #0000FF
Cyan #FF00FF Red #FF0000
Green #00FF00 White #FFFFFF
Maroon #800000 Yellow #FFFF00
Text-align Property
The text-align property is used to control the horizontal positioning of blocks of text in a web page.
You can align text to the left, right, center, or justified. By default, most web browsers align text to the
left.
Consider the code given below :
<style type = ‘‘text/css’’>
p {text-align: right}
h1 {text-align: center}
h4 {text-align: justify}
</style>
67