HTML and CSS Reference
In-Depth Information
The @import directive allows style sheets to be grouped and joined together, though
some might wonder what the value of this function is given what linked styles provide.
N OTE Some CSS developers use the @import directive to perform a weak form of browser
selection, because many older CSS implementations do not support the directive. The basic idea
of the trick is to put sophisticated style rules in an @import style sheet and leave basic styles in
the style block. This trick should be avoided, particularly given that some browsers, notably
versions of Internet Explorer, will cause a disturbing flash effect when loading imported styles.
Inline Styles
You can apply styles directly to elements in a document using the core attribute style , as
shown next. As the closest style-inclusion method to a tag, inline styles take precedence
over document-wide or linked styles.
<h1 style="font-size: 48px; font-family:Arial, Helvetica, sans-serif;
color: green;"> CSS Test </h1>
Given the tight intermixture of style into markup, this scheme should be used sparingly.
Note that some features of CSS, particularly pseudo-class-related values such as link states,
may not be settable using this method. Further note that there is no way to set media-
specific style rules inline on individual elements.
CSS Measurements
CSS supports a number of measurements. In most cases, they involve a number, and CSS
supports both positive and negative integer values, like 3 and -14, as well as real numbers
like 3.75. Very often the numbers are found with units; for example,
p {margin: 5px;} /* all margins set to 5 pixels */
But in a few cases they may not have units, as the measurement may be contextual from
the meaning of the property:
p {line-height: 2;} /* double spaced */
When a measurement is zero, there is no need for a unit,
* {margin: 0;}
but it won't hurt to include one:
* {margin: 0px;}
Commonly, absolute length units like inches ( in ), centimeters ( cm ), millimeters ( mm ),
points ( pt ), and picas ( pc ) are used. These absolute measures should be used when the
physical characteristics of the display medium are well understood, such as in printing. We
also might use relative measures that can scale, such as em units, ex values, percentage, or
pixels. Table 5-3 summarizes these units of measure.
Search WWH ::

Custom Search