HTML Color Names
HTML Colors: Names, HEX, RGB, and HSL
You can style elements in HTML using the style attribute with various color formats like:
- Hex codes
- RGB values
- HSL values
1. Color Names in HTML
HTML supports standard color names like red, blue, green, orange, etc.
<p style="color: red;">This is red text using color name.</p>
2. Hex Color Codes (#rrggbb)
Hex codes define colors using hexadecimal values. Each pair represents red, green, and blue.
<p style="color: #00ff00;">This is green text using hex code.</p>
3. RGB Colors (rgb(red, green, blue))
RGB allows you to define colors using numeric values (0-255) for red, green, and blue.
<p style="color: rgb(0, 0, 255);">This is blue text using RGB.</p>
4. HSL Colors (hsl(hue, saturation, lightness))
HSL stands for Hue, Saturation, and Lightness. Hue is a degree (0-360), saturation & lightness are percentages.
<p style="color: hsl(300, 100%, 50%);">This is purple text using HSL.</p>
Summary Table
Format | Example Value | Used In |
---|---|---|
Name | red, green | Easy use |
Hex | #ff0000, #00ff00 | Web design |
RGB | rgb(255,0,0) | Precise color control |
HSL | hsl(0, 100%, 50%) | Modern design & themes |