15 HTML - Colors
15 HTML - Colors
HTML - Colors
HTML Colors are a way of specifying the appearance of web elements. Colors are very
important aspects of web design, as they not only enhance the visual appeal but also
influence user behavior. They are also used to evoke emotions and highlight important
content.
In HTML, colors are generally used to color backgrounds, borders and texts.
Color Names: We can specify color names directly like green, blue or red.
HEX Color Codes: A six-digit code representing the amount of red, green, and
blue that makes up the color.
RGB Color Values: This value is specified using the rgb() property.
Try to click the icon run button to run the following HTML code to see the output.
Open Compiler
<!DOCTYPE html>
<html>
<head>
<title>Setting Text Color</title>
</head>
<body>
<h2 style="color: Fuchsia;">
Setting Text Color in HTML
</h3>
<p style="color: Teal;">
https://www.tutorialspoint.com/html/html_colors.htm 1/6
7/17/24, 11:17 AM HTML - Colors
Explore our latest online courses and learn new skills at your own pace. Enroll and
become a certified expert to boost your career.
Open Compiler
<!DOCTYPE html>
<html>
<head>
<title>Setting Background Color</title>
</head>
<body>
<h2 style="background-color: Fuchsia;">
Setting Background Color in HTML
</h2>
<p style="background-color: Teal; padding: 5px;">
This line is created using paragraph tag
and its background color is <b>Teal</b>.
</p>
<p style="background-color: SlateBlue;">
This is another line created using paragraph
tag and its background color is <b>SlateBlue</b>.
</p>
</body>
</html>
https://www.tutorialspoint.com/html/html_colors.htm 2/6
7/17/24, 11:17 AM HTML - Colors
Open Compiler
<!DOCTYPE html>
<html>
<head>
<title>Setting Border Color</title>
</head>
<body>
<h2 style="border: 2.5px solid Fuchsia;">
Setting Border Color in HTML</h2>
<p style="border: 2.5px dotted Teal; padding: 5px;">
This line is created using paragraph
tag and its border color is <b>Teal</b>.
</p>
<p style="border: 2.5px dashed SlateBlue; padding: 5px;">
This is another line created using paragraph
tag and its border color is <b>SlateBlue</b>.
</p>
</body>
</html>
https://www.tutorialspoint.com/html/html_colors.htm 3/6
7/17/24, 11:17 AM HTML - Colors
Open Compiler
<!DOCTYPE html>
<html>
<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>
https://www.tutorialspoint.com/html/html_colors.htm 4/6
7/17/24, 11:17 AM HTML - Colors
https://www.tutorialspoint.com/html/html_colors.htm 5/6
7/17/24, 11:17 AM HTML - Colors
https://www.tutorialspoint.com/html/html_colors.htm 6/6