Home › Learn › HTML and CSS › CSS basics

Selectors and colors

Lesson 6 of 20. Your first CSS rules.

CSS is rules: a selector saying which elements, then declarations in braces saying what to change. h1 { color: rgb(47, 111, 237); } colors every h1. Declarations are property: value;. Rules go in a <style> element in the head (or a separate .css file linked from it).

Colors can be written as rgb(r, g, b), as hex #2f6fed (the same color), as names like tomato, or as hsl(...). Whatever you write, the browser stores an rgb() value, which is what the checks read back.

h1 { color: #2f6fed; }
p { color: rgb(95, 100, 112); }

Your task

In the style block, make every h1 the color rgb(47, 111, 237) and every p the color rgb(95, 100, 112).

Hint 1

h1 { color: rgb(47, 111, 237); }

Hint 2

A second rule for p with the other color.

Show the solution
<!doctype html>
<html>
<head>
<style>
h1 { color: rgb(47, 111, 237); }
p { color: rgb(95, 100, 112); }
</style>
</head>
<body>
<h1>Colors</h1>
<p>Blue heading, gray text.</p>
</body>
</html>
Preview

    Renders in the preview as you type; the checks read the rendered page.