HTML and CSS Reference
In-Depth Information
Without appropriate discipline, external stylesheets can become large
and unwieldy. When creating stylesheets, include only those styles that
are common to the pages using the sheet. If a set of styles is needed for
only one or two pages, you are better off isolating them in a separate
sheet or adding them to those documents using document-level styles.
Otherwise, you may find yourself expending an exorbitant amount of ef-
fort counteracting the effects of external styles in many individual doc-
uments. The pros and cons of document-level styles
Document-level styles are most useful when creating custom docu-
ments. They let you override one or more rules in your externally
defined style to create a slightly different document.
You might also want to use document-level styles to experiment with
new style rules before moving them to your stylesheets. By adding and
changing rules using document-level styles, you eliminate the risk of
adding a broken style to your stylesheets, breaking the appearance of
all the documents that use that sheet.
The biggest problem with document styles is that you may succumb to
using them in lieu of creating a formal, external stylesheet to manage
your document collection. It is easy to simply add rules to each docu-
ment, cutting and pasting as you create new documents. Unfortunately,
managing a collection of documents with document-level styles is tedi-
ous and error-prone. Even a simple change can result in hours of editing
and potential mistakes.
As a rule of thumb, any style rule that impacts three or more documents
should be moved to a stylesheet and applied to those documents using
the <link> tag or @import at-rule. Adhering to this rule as you create
your document families pays off in the long run when it is time to change
your styles.
Search WWH ::

Custom Search