Tsallaka zuwa abun ciki
Justice Tech School

HTML Colors

Colours are set with CSS. You can use a colour name (tomato), a hex code (#166534), rgb(22, 101, 52) or hsl(142, 64%, 24%).

Use color for text and background-color for the background. Always check that text has enough contrast against its background so it is readable.

Example
<h2 style="color: tomato">Tomato text</h2>
<p style="background-color: #dcfce7; padding: 8px">Light green background</p>
<p style="color: white; background-color: rgb(22, 101, 52); padding: 8px">White on dark green</p>

Exercise

Set the text colour.

<p style=": blue">Hi</p>

Quiz Test

Which is a valid hex colour?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.