HTML and CSS Reference
In-Depth Information
/* Import corporate style sheet */
@import url(http://example.com/css/hq.css);
/* Local styles begin here */
body { padding: 36px; }
</style>
An import directive must appear before any other CSS statements with the
exception of comments and other import directives. Because imported iles
can also contain import directives, it is possible to construct ininite loops if
you are not careful.
CSS statements in a document's style element apply only to that document.
As a general rule, style elements in a document head should be placed ater
any style sheets referenced in link elements. All rules for a given HTML ele-
ment are combined. If the browser has more than one CSS rule to apply to a
given element property, the last one found will apply.
A CSS statement consists of a selector expression that determines which
HTML elements the statement applies to, followed by one or more rules
enclosed in curly braces. Each rule is composed of a property name and a
value expression separated by a colon (:) . Each rule is separated from the
preceding rule by a semicolon (;) . For example, the following CSS state-
ment causes all level-three headings in a document to be rendered in a bold,
redĀ font:
h2 { font-weight: bold; color: red; }
he actual layout of a CSS statement is lexible. Blanks, carriage returns,
tabs, and other white space are ignored, allowing the author to format a style
sheet for readability. Comments can be added for even more readability. he
CSS statement just shown could be written like this without any diference in
meaning: 1
h2 { /* multiple lines */
font-weight:bold; /* don't matter */
color:red;
}
1. he inal semicolon before the closing curly brace can be omitted. I put it there because, like many pro-
grammers, I'm always adding to my previous work, and because the extra punctuation is inconsequential.
A missing semicolon between two CSS statements will cause both statements to be ignored.
 
Search WWH ::




Custom Search