</> Code Corner

CSS · CSS Tutorial · Lesson 6

CSS Colors

Text, background and border colors.

Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.

Example

<h1 style="background-color:DodgerBlue;">Background color</h1>
<p style="color:Tomato;">Text color</p>
<h2 style="border:3px solid Violet;">Border color</h2>
<div style="background-color:rgba(255, 99, 71, 0.4); padding:10px;">40% opacity tomato</div>
<div style="background-color:#04AA6D; color:white; padding:10px;">HEX #04AA6D</div>
Format Example
Name tomato
RGB rgb(255, 99, 71)
HEX #ff6347
HSL hsl(9, 100%, 64%)
Shorthand HEX #f00 = #ff0000

Keep reading “CSS Colors”

Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.

Chat with us 👋