Skip to Main Content
Creating a Website: The Missing Manual, 3rd Edition
book

Creating a Website: The Missing Manual, 3rd Edition

by Matthew MacDonald
May 2011
Beginner content levelBeginner
584 pages
17h 42m
English
O'Reilly Media, Inc.
Content preview from Creating a Website: The Missing Manual, 3rd Edition

Colors

It isn’t difficult to inject some color into your web pages. Style sheet rules have two color-related properties, listed in Table 6-1. You’ll learn about the types of values you can use when setting colors (color names, color codes, and RGB values) in the following sections.

Table 6-1. Color properties.

Property

Description

Common Values

Can Be Inherited?

color

The color of the text. This is a handy way to make headings or emphasized text stand out.

A color name, color code, or RGB color value.

Yes

background-color

The color behind the text for just that element.

A color name, color code, or RGB color value. You can also use the word “transparent.”

No[a]

[a] The background-color style property doesn’t use inheritance (Inheritance). If you give the <body> section of a page a blue background and you then place a heading on the page, the heading doesn’t inherit the blue background. However, there’s a trick. If you don’t explicitly assign a background color to an element, its color is transparent. This means the color of the containing element shows through, which has the same effect as inheritance. So the heading in this example still ends up with the appearance of a blue background.

The color property is easy to understand; it’s the color of your text. The background-color property is a little more unusual.

If you apply a background color to the <body> element of a web page, the whole page adopts that color, as you might expect. However, if you specify a background color for an individual ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Creating a Website: The Missing Manual, 4th Edition

Creating a Website: The Missing Manual, 4th Edition

Matthew MacDonald
Learn to Build a Website

Learn to Build a Website

Cassidy Williams, Camryn Williams

Publisher Resources

ISBN: 9781449306823Supplemental ContentErrata Page