Web Technologies - Old Questions
6. What are the color attributes in HTML? Explain.
Colors are very important to give a good look and feel to your website. We can specify colors on page level using <body> tag or you can set colors for individual tags using bgcolor attribute.
The <body> tag has following attributes which can be used to set different colors −
- bgcolor − sets a color for the background of the page.
- text − sets a color for the body text.
- alink − sets a color for active links or selected links.
- link − sets a color for linked text.
- vlink − sets a color for visited links − that is, for linked text that you have already clicked on.
There are following three different methods to set colors in your web page −
- Color names − We can specify color names directly like green, blue or red.
- Hex codes − A six-digit code representing the amount of red, green, and blue that makes up the color.
- Color decimal or percentage values − This value is specified using the rgb( ) property.
E.g.
<!DOCTYPE html>
<html>
<head>
<title>HTML Colors by Name</title>
</head>
<body text = "blue" bgcolor = "green">
<p>Use different color names for for body and table and see the result.</p>
<table bgcolor = "black">
<tr>
<td>
<font color = "white">This text will appear white on black background.</font>
</td>
</tr>
</table>
</body>
</html>