
260
Part II
Designing and Crafting Basic Pages
The formula for creating specificity is as follows:
Total inline styles, total ID selectors, total class and
pseudo-class selectors, total tag elements
Inline styles are the most specific—and the most rarely used these days—so they trump any other
type of selector. If two rules have the same specificity and are applied to the same selection, the rule
that comes later in the style sheet—because it is physically closer to the code—wins.
How styles are applied
CSS applies style formatting to your page in one of three ways:
Via an external, linked style sheet
■■
Via an embedded style
■■
Via inline style rules
■■
External style sheets
An external style sheet is a file containing the CSS rules; it links one or more Web pages. One ben-
efit of linking to an external style sheet is that you can customize and change the appearance of a
Web site quickly and easily from one file.
Two different methods exist for working with an external style sheet: the
link method and the
import method. Dreamweaver initially defaults to the link method, but you can also choose
import if you prefer.
For the
link method, a line of code is added outside of the <style> tags, as follows:
<link href=”mainstyle.css” rel=”style sheet” type=”text/css”>
The import method writes code within the style tags, as follows:
<style type=”text/css”>
<!--
@import url(“newstyles.css”);
-->
</style> ...