HTML Color
HTML Color Tags and Attributes
| HTML Tag | HTML Attribute | Description |
|---|
| <body> | bgcolor | page background color |
| <table> | bgcolor | table background color |
| <tr> | bgcolor | table row background color |
| <th> | bgcolor | table header cell background color |
| <td> | bgcolor | table data cell background color |
| <body> | text | page text color |
| <font> | color | text color |
| <table> | bordercolor | table border color |
| <tr> | bordercolor | table row border color |
| <th> | bordercolor | table header cell border color |
| <td> | bordercolor | table data cell border color |
| <table> | bordercolorlight | table light border color |
| <tr> | bordercolorlight | table row light border color |
| <th> | bordercolorlight | table header cell light border color |
| <td> | bordercolorlight | table data cell light border color |
| <table> | bordercolordark | table dark border color |
| <tr> | bordercolordark | table row dark border color |
| <th> | bordercolordark | table header cell dark border color |
| <td> | bordercolordark | table data cell dark border color |
| <style> | - | Define CSS style |
| <body> | link | links color |
| <body> | vlink | visited links color |
| <body> | alink | selected links color |
HTML Code Example
HTML has its own color attributes, but It is better to use CSS Color styling.
Example:
<p><font color="#FF0000">Red Text</font></p>
<p><font color="green">Green Text</font></p>
<p><font color="rgb(0,0,255)">Blue Text</font></p>
Red Text
Green Text
Blue Text
HTML Background Color - <body>, <table>, <tr>, <th>, <td> tags
The bgcolor attribute is used with the <body>,<table>,<tr>,<th>,<td> tags.
The page background color is set in the <body> tag in one of the three formats below.
The table and table cells background colors are set like the example below:
Example:
<body bgcolor="#808080">
<body bgcolor="gray">
<body bgcolor="rgb(128,128,128)">
<table border="1" width="100%" bgcolor="#FFFF00">
<tr>
<th bgcolor="#808000"> </th>
<th> </th>
</tr>
<tr>
<td> </td>
<td bgcolor="#DDDDDD"> </td>
</tr>
<tr bgcolor="#00FFFF">
<td> </td>
<td> </td>
</tr>
</table>
HTML Text Color - <text>, <font> tags
Example:
<body text="#000000">
<h1><font color="#000000">Black Text Color</font></h1>
<p><font color="#FF0000">Red Text Color</font></p>
HTML Table Color - <table>, <tr>, <th>, <td> tags
Example:
<table border="1" width="100%" bgcolor="blue" bordercolor="#000000" bordercolorlight="#008000" bordercolordark="#FF00FF">
<tr>
<th bgcolor="#808080" bordercolorlight="#008000" bordercolordark="#808000" bordercolor="#000000"> </th>
<th > </th>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td bgcolor="#808080" bordercolorlight="#008000" bordercolordark="#808000" bordercolor="#000000"> </td>
<td> </td>
</tr>
<tr bgcolor="#808080" bordercolorlight="#00ffff" bordercolordark="#ffff00" bordercolor="#ffffff">
<td> </td>
<td> </td>
</tr>
</table>
HTML Style Color
style attribute
The style attribute is used to define CSS styling inside a specific HTML tag.
Example:
<html>
<head>
</head>
<body>
<p style="color: #00FF00">Some green words</p>
<p style="color: #0000FF">Some blue words</p>
</body>
</html>
style tag
The <style> tag is used to define CSS styling in the head section.
Example:
<html>
<head>
<style type="text/css">
p { color: #00FF00; }
</style>
</head>
<body>
<p>Some green words</p>
</body>
</html>
HTML Link Color - <a>, <font> tags
Example:
<a href="other_page.htm">
<font color="#008000">Green link color</font>
</a>
HTML Color Names and Codes Table
| | black | #000000 | rgb(0,0,0) |
| | silver | #C0C0C0 | rgb(192,192,192) |
| | gray | #808080 | rgb(128,128,128) |
| | white | #FFFFFF | rgb(255,255,255) |
| | purple | #800080 | rgb(128,0,128) |
| | fuchsia | #FF00FF | rgb(255,0,255) |
| | maroon | #800000 | rgb(128,0,0) |
| | red | #FF0000 | rgb(255,0,0) |
| | olive | #808000 | rgb(128,128,0) |
| | yellow | #FFFF00 | rgb(255,255,0) |
| | green | #008000 | rgb(0,128,0) |
| | lime | #00FF00 | rgb(0,255,0) |
| | teal | #008080 | rgb(0,128,128) |
| | aqua | #00FFFF | rgb(0,255,255) |
| | navy | #000080 | rgb(0,0,128) |
| | blue | #0000FF | rgb(0,0,255) |
See also