Color


Collapse Content

color

The color property is used for setting the color of text, while background-color is used to set the background color of an HTML element. Color can also be used for other properties, such as border-color.

Until now we used keywords for color, such as red and green. Here are some other common keywords you can use:

Keyword RGB hex values
black #000000
silver #c0c0c0
gray #808080
white #ffffff
maroon #800000
red #ff0000
purple #800080
fuchsia #ff00ff
green #008000
lime #00ff00
olive #808000
yellow #ffff00
navy #000080
blue #0000ff
teal #008080
aqua #00ffff
orange #ffa500


See Mozilla's Color value page for a list of all color keywords.

You can also specify colors more exactly with RGB hexadecimal values (shown on the right of the table), which describe how much red, green and blue is in a color. For example, Black has no red, green or blue, so it's hex value is 00 for each color or #000000 overall. You usually can use a HTML/CSS editor or color picker tool to set these, so we're not going to cover the details here.

Challenge

Can you set the color for h1, h2 and h3 headings to midnightblue?
(You can do this all with one rule set.)

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Contact Us
Sign in or email us at [email protected]