Colors are one of the key visual elements of websites. They help set the tone, highlight content, and define overall design. In HTML, there are several ways to define colors.
In HTML, you can define colors by name (e.g., red), HEX codes (e.g., #ff0000), RGB format (e.g., rgb(255, 0, 0)), or HSL format (e.g., hsl(0, 100%, 50%)).
Code Details
<p style="color: red;">Red text</p>
<p style="color: #00ff00;">Green text (HEX)</p>
<p style="color: rgb(0, 0, 255);">Blue text (RGB)</p>
<p style="color: hsl(60, 100%, 50%);">Yellow text (HSL)</p>
Preview
Red text
HEX (hexadecimal) codes start with a # and contain six characters. The first two define red, the next two green, and the last two blue.
RGB format uses three numbers in parentheses: red, green, and blue. Each value ranges from 0 to 255. For example, rgb(255, 0, 0) represents red.
HSL (Hue, Saturation, Lightness) is another way to describe colors. Hue defines the color’s angle in degrees, Saturation defines intensity, and Lightness defines brightness.
HTML supports more than 140 predefined color names, such as red, blue, green, orange, etc. These are easy to read and quick to apply.
It's important to ensure sufficient contrast between text and background color. Otherwise, the content may become hard to read. Use light text on a dark background or vice versa.
Always consider visually impaired users when choosing colors. Avoid combinations that are unreadable for colorblind users. Content should not rely solely on color.
<!DOCTYPE html>
<html>
<head>
<style>
body {
Drag the item here
}
</style>
</head>
<body>
<blockquote>
<p>When you have something to say, silence is a lie.</p>
<footer>- Jordan B. Peterson</footer>
</blockquote>
</body>
</html>
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.