HTML Colors
HTML colors are used to change text or background colors. You can use predefined color names or color codes like HEX, RGB, HSL, RGBA, and HSLA.
1. Predefined Color Names
HTML has many color names like red, blue, green, orange, etc.
<p style="color:red">This is red text.</p> <p style="background-color:blue; color:white">Blue background</p>
This is red text.
Blue background
2. HEX Colors
Use #RRGGBB to define colors in hexadecimal.
<p style="color:#ff5733">Orange color using HEX</p>
Orange color using HEX
3. RGB Colors
Use rgb(red, green, blue) to define colors with numbers from 0-255.
<p style="color:rgb(0,128,0)">Green color using RGB</p>
Green color using RGB
4. RGBA Colors
RGBA is RGB with alpha (opacity). Value 0 = transparent, 1 = solid.
<p style="color:rgba(255,0,0,0.5)">Semi-transparent red</p>
Semi-transparent red
5. HSL Colors
HSL = Hue, Saturation, Lightness
<p style="color:hsl(200,100%,50%)">HSL blue</p>
HSL blue
6. HSLA Colors
HSLA is HSL with alpha (opacity).
<p style="color:hsla(120,100%,25%,0.5)">Semi-transparent dark green</p>
Semi-transparent dark green
Next Lesson → HTML Block and Inline Elements
Previous Lesson → HTML Quotations & Special Elements