HTML and CSS Reference
In-Depth Information
Percentages
A percentage value is a <number> followed by a percentage sign ( % ), and is represented
in value syntax as <percentage> . Examples would include 50% and 33.333% . Percentage
values are always relative to another value, which can be anything—the value of another
property of the same element, a value inherited from the parent element, or a value of
an ancestor element. Any property that accepts percentage values will define any re-
strictions on the range of allowed percentage values, and will also define the way in
which the percentage is relatively calculated.
Distances
Many CSS properties, such as margins, depend on length measurements to properly
display various page elements. It's no surprise, then, that there are a number of ways
to measure length in CSS.
All length units can be expressed as either positive or negative numbers followed by a
label (although some properties will accept only positive numbers). You can also use
real numbers—that is, numbers with decimal fractions, such as 10.5 or 4.561. All length
units are followed by short abbreviation (usually two characters) that represents the
actual unit of length being specified, such as in (inches) or pt (points). The only ex-
ception to this rule is a length of 0 (zero), which need not be followed by a unit.
These length units are divided into two types: absolute length units and relative length
units .
Absolute Length Units
We'll start with absolute units because they're easiest to understand, despite the fact
that they're almost unusable in regular web design. The six types of absolute units are
as follows:
Inches ( in )
As you might expect, this notation refers to the inches you'd find on a ruler in the
United States. (The fact that this unit is in the specification, even though almost
the entire world uses the metric system, is an interesting insight into the perva-
siveness of U.S. interests on the Internet—but let's not get into virtual sociopolitical
theory right now.)
Centimeters ( cm )
Refers to the centimeters that you'd find on rulers the world over. There are 2.54
centimeters to an inch, and one centimeter equals 0.394 inches.
Millimeters ( mm )
For those Americans who are metric-challenged, there are 10 millimeters to a cen-
timeter, so an inch equals 25.4 millimeters, and a millimeter equals 0.0394 inches.
 
Search WWH ::




Custom Search