HTML and CSS Reference
In-Depth Information
his code applies a thin black border to all paragraph elements in the page
with that class attribute value, as in
<p class="in-a-box">...</p>
Diferent kinds of HTML elements can be selected by their class attribute
values as well. A CSS statement beginning with a dot followed by a class name
is the same as *.classname and applies the style rule to every element that has
that class attribute value.
Any number of selector expressions can be grouped into a single expression
by separating the individual expressions with commas. For example, to style a
page so that all headings are in a diferent font family than the body text, use
CSS statements like these:
body { font-family: georgia,times,serif; }
h1,h2,h3,h4,h5,h6 { font-family: verdana,helvetica,sans-serif; }
he values for the font-family property are usually given as a list of prefer-
ences. In this code, all headings are rendered in the Verdana font if it exists
on the reader's computer. If the Verdana font is not found, the browser uses
Helvetica. If that's not found, the browser can use the default sans serif font to
render the headings. See the section “Typography” for more on font properties.
An element can be selected based on its status as the descendent of another
element just by separating the two element names with blanks. For example,
this code sets the color of all links inside a block quote to dark green:
blockquote a { color: darkgreen; }
Here are some more examples of descendent selectors:
table td a { text-decoration: none; } /* not underlined */
#main-title strong { font-size: 120%; }
footer address { font: bold 10pt courier,monospace; }
div.aside ul { background-color: rgb(100,100,100); }
div.aside li { color: white; list-style-type: square; }
A descendent element is selected no matter how deeply it is nested inside
the parent element. To select an element that is the irst-generation child of a
parent element, the following syntax is used:
body > div { margin-top: 0px; margin-bottom: 36px; }
Search WWH ::

Custom Search