Specifying Color in HTML 75
HTML
Overview
Specifying Color in HTML
Web Design in a Nutshell, eMatter Edition
Avoid adding extra or redundant tags
Extra and redundant HTML tags add unnecessary bytes to the size of your
HTML file causing slightly longer download times. They also make the
browser work harder to parse the file, further increasing display times. One
example of redundant tagging is multiple and identicaltags within a
sentence, a common side effect created after making small edits with a
WYSIWYG authoring tool.
Name your files according to the following guidelines:
- Use proper suffixes. HTML documents require the suffix.html(or.htmif on a
Windows server). Suffixes for a number of common file types can be found in
Table 4-3. - Avoid spaces and special characters such as ?, %, #, etc. in file names. It is
best to limit file names to letters, numbers, underscores (in place of spaces),
hyphens and periods. - File names are case-sensitive in HTML. Consistently using all lowercase letters
in file names, while certainly not necessary, may make them easier to remem-
ber.
Mind your line endings.
Although not mandatory, it is accepted practice to keep your line lengths to
under 80 characters to make the document easier to view on a wide variety of
platforms.
In addition, you should be certain that you set your HTML editor to use Unix-
style Line Feed (LF) line endings, particularly if you have a Unix server.*
Other line ending possibilities are Carriage Returns (CR) used by Macintosh,
and Carriage Return + Line Feed (CR+LF) used by PCs. Some editors, such as
BBEdit, allow you to set the line feed style under the Save Options.
Line breaks and extra spaces can create unwanted white space in
certain contexts. For instance, if you have a string of graphics that
should abut seamlessly, adding a line break or a space between the
<img>tags will introduce extra space between the graphics (even
though, technically, it shouldn’t). In addition, extra spaces within
and between table cells (<td>tags) can add unwanted (and mysteri-
ous) spaces in your table. This is discussed further in Chapter 10.
Specifying Color in HTML
You can specify the color of certain page elements using HTML tags. There are
two methods for specifying colors in web documents: by RGB values and by color
name.
- This tip taken fromCreative HTML Design, by Lynda Weinman and William Weinman, pub-
lished by New Riders Publishing.