HTML
HTML introduction
HTML basics
HTML text format 1
HTML text format 2
HTML text format 3
HTML links
HTML images
HTML image maps
HTML forms
Fieldset/legend tags
Email links
HTML labels
HTML tables
HTML frames
HTML backgrounds
HTML colors
HTML color shades
HTML color usage
HTML marquees
HTML fonts
HTML entities
HTML stylesheets
HTML layout
HTML div/span
HTML audio
HTML video
HTML objects
HTML d'load media
HTML meta tags
HTML scripts
HTML declarations
HTML head section
HTML document types
HTML tag rules
HTML things to avoid
URL formatting
Encoding and decoding
HTML use/access
HTML publish work
History of HTML
HTML summary

Programming

Programming intro
Java

Markup

First webpage guide
XHTML

Style & Layout

CSS

Browser scripting

Javascript
VBScript
AJAX

Server scripting

PHP
ASP

Making money online

Make money online

HTML color usage

Knowing how to set color is one thing, but doing it correctly as well as choosing the right color is another thing. Using color correctly both for yourself (in your code) and for your visitors (on the actual webpage) is an integral part of web development.

This lesson focuses on:

Color naming convention

In the lesson on HTML colors, we discussed how you can set a color in three different ways -- by color name, RGB value, or hexadecimal value.

While it is possible to set a color by color name or RGB value, the best way to do it is by hexadecimal code. If you set colors by hexadecimal code:

Hexadecimal color naming shortcut

When declaring the hexadecimal color value for an element, instead of using the full 6 digit value, you can shorten it down to three, that is if the color code consists of three pairs of repeating digits.

Example:

<body bgcolor="#ffffff"> <body bgcolor="#aa2233"> <body bgcolor="#114455"> <body bgcolor="#ffaa44">

can be shortened to:

<body bgcolor="#fff"> <body bgcolor="#a23"> <body bgcolor="#145"> <body bgcolor="#fa4">

Color schemes

When creating a color scheme, you should always make sure that the background color goes good with the text color and images on a page as well as the general appearance of the page (everything has to work together). The general rule in web design is dark text on a light background and you will see this combination on the majority of websites out there. There are some websites that do have light text on a dark background, and to their credit, they do a good job at it as well. So it is possible to make a webpage look good with both dark text on a light background or light text on a dark background but you should stick to light text on a dark background as that is what people are used to seeing and that is the general rule on the web.

Examples of good background/text color combinations:

Black text on a gray background Medium blue text on a very light blue background Orange text on a black background Black text on a white background Green text on a light blue background

Choosing a good color scheme can sometimes be a difficult and tricky process. To help you with this, check out the website colorblender.com. You choose a color or colors, and it will tell you in real-time what color(s) go good with it.

Practice

Online code editor
Practical examples
Practical exercises
Step-by-step tutorials

Reference

Terms glossary
Reference material

Rate this site

Rate this site
Visitor comments