CSS, DHTML, and Ajax, Fourth Edition

Throughout this book, you'll need to enter different values to define different properties. These values come in various forms, depending on the need of the property. Some values are straightforwarda number is a numberbut others have special units associated with them.

Values in chevrons (< >) represent one type of value (Table i.1). Words that appear in code font are literal values and should be typed exactly as shown.

Table i.1. Value Types

VALUE TYPE

WHAT IT IS

EXAMPLE

<number>

A number

1, 2, 3

<length>

A measurement of distance

1in or size

<color>

A chromatic expression

red

<percentage>

A proportion

35%

<URL>

The absolute or relative path to a file on the Web

http://www.mySite.net/bob/graphics/image1.gif

Length Values

Length values come in two varieties:

  • Relative lengths, which vary depending on the computer being used (Table i.2).

    Table i.2. Relative Length Values[*]

    UNIT

    NAME

    WHAT IT IS

    EXAMPLE

    em

    Em

    Relative to width of the letter M for the font

    3em

    ex

    x-height

    Relative to height of the lowercase x of that font

    5ex

    px

    Pixel

    Relative to the monitor's resolution

    125px

    [*] Internet Explorer treats pixels as an absolute value rather than a relative one.

  • Absolute values, which remain constant regardless of the hardware and software being used (Table i.3).

    Table i.3. Absolute Length Values

    UNIT

    NAME

    WHAT IT IS

    EXAMPLE

    pt

    Point

    72pt = 1inch

    12pt

    pc

    Picas

    1 pc = 12 pt

    3pc

    mm

    Millimeters

    1mm = .24pc

    25mm

    cm

    Centimeters

    1cm = 10mm

    5.1cm

    in

    Inches

    1in = 2.54cm

    8.25ini

I generally recommend using pixel sizes to describe font sizes for the greatest stability between operating systems and browsers.

Color Values

You can describe color on the screen in a variety of ways (Table i.4), but most of these descriptions are just different ways of telling the computer how much red, green, and blue are in a particular color.

Table i.4. Color Values

FORMAT

WHAT IT IS

EXAMPLE

#RRGGBB

Red, green, and blue hex-code value of a color (00-99,AA-FF)

CC33FF or C3F

rgb(R#,G#,B#)

Red, green, and blue numeric-values of a color (0-255)

rgb(204,51,255)

rgb(R%,G%,B%)

Red, green, and blue percentage values of a color (0-100%)

rgb(81%,18%,100%)

<name>

The name of the color

Purple

Percentages

Many of the properties in this book can have a percentage as their value. The behavior of this percentage value depends on the property being used.

URLs

A Uniform Resource Locator (URL) is the unique address of something on the Web. This resource could be an HTML document, a graphic, a CSS file, a JavaScript file, a sound or video file, a CGI script, or any of a variety of other file types. URLs can be local, simply describing the location of the resource relative to the current document; or global, describing the absolute location of the resource on the Web and beginning with http://.

In addition, throughout the book, I use links in the code examples. I use the number sign (#) as a placeholder in links that can be directed to any URL you want:

<a href="#">...</a>

The number sign is shorthand that links to the top of the current page. Replace these with your own URLs as desired.

Browser-Safe Colors

Certain colors always display properly on any monitor. These colors are called browser-safe colors. You'll find them fairly easy to remember because their values stay consistent. In hexadecimal values, you can use any combination of 00, 33, 66, 99, CC, and FF. In numeric values, use 0, 51, 102, 153, 204, or 255. In percentages, use 0, 20, 40, 60, 80, or 100.

Категории