
Example:
<html>
<head>
<title>Four Ways To Include Styles</title>
<link rel="stylesheet" type="text/css" href="linked-styles.css" /> [linked]
<style type="text/css"><!-- [embedded]
@import url(imported-styles.css); [imported]
body {
background-color: #000000;
color: #ffffff;
font-family: Verdana,Tahoma,Arial,Helvetica,sans-serif;
}
--></style>
</head>
<body>
<h1>Four Ways To Include Styles</h1>
<p style="text-align: justify">This paragraph will be [inline]
justified on both the left and right margins. This is accomplished through
the use of an inline style. Notice also that this HTML document includes
linked, embedded, and imported style sheets. It is not common for all four
methods to be used in one HTML document, however, as it is likely to
introduce conflicts between style rules.</p>
</body>
</html>
<html>
<head>
<title>Classes and Identifiers</title>
<style><!--
.sky { background-image: url(sky.jpg); } [class selector defined]
#content { margin: 0 10%; } [id selector defined]
--></style>
</head>
<body>
<div id="content"> [id selector applied]
<h1>Classes and Identifiers</h1>
<p class="sky">This paragraph will sit on top of a [class selector applied]
background image of the sky. It is enclosed within a division that is
centered on the screen, with margins on either side that equal 10% of the
width of the screen.</p>
</div>
</body>
</html>
a:link { color: #006600; font-weight: bold; }
a:visited { color: #666666; font-weight: bold; }
a:hover { color: #000000; background-color: #ffffcc; }
| Absolute Values | Relative Values |
|---|---|
|
|
This chart represents only a partial listing of the properties that are part of the Casccading Style Sheet Level 1 specification. For a full listing, see the W3C specification.
| Color and Background Properties | |||||
|---|---|---|---|---|---|
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| color | <color> | Determined by browser | All elements | Yes | |
|
Specifies the color of an element. A color value is a numerical RGB specification. Example:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| background-color | <color>
transparent |
transparent | All elements | No | |
|
Specifies the background color of an element. A color value is a numerical RGB specification. Background colors are almost always specified in conjunction with a foreground color to make sure that colors are readable and have good contrast (the foreground color may be inherited). Examples:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| background-image | url(<filename>)
none |
none | All elements | No | |
|
Sets the background image of an element. To ensure compatibility across browser environments, background-image should, in most cases, be accompanied by background-color (some browsers do not display the background image). Examples:
|
|||||
|
|
|||||
| Font Properties | |||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| font-family | <family-name>
serif sans-serif cursive fantasy monospace |
Determined by browser | All elements | Yes | |
|
Any font family name may be used. Font family names that include a white space (e.g., Times New Roman) must be enclosed in single or double quotation marks. If more than one font family is specified, the browser will use the first one it finds on the local computer. Generic fonts (e.g., serif, sans-serif) will display the first font from that family available on the user's computer. It's a good idea to include a generic font in case none of the specified fonts is available. Examples:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| font-size | xx-small
x-small small medium large x-large xx-large <length> <percentage> |
medium | All elements | Yes | |
|
Modifies the size of the displayed font. Absolute lengths (e.g., 9pt, 0.25in) should be used sparingly because of variations in different browsing environments. Fonts with absolute lengths can very easily be too small or too large for a user. Style sheets using the font-size property should be tested in several browser environments. Examples:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| font-style | normal
italic |
normal | All elements | Yes | |
|
The font-style property is context-sensitive. Examples:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| font-weight | normal
bold 100 200 300 400 500 600 700 800 900 |
normal | All elements | Yes | |
|
Defines the weight (boldness) of an element. Examples:
|
|||||
|
|
|||||
| Text Properties | |||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| text-transform | none
capitalize uppercase lowercase |
none | All elements | Yes | |
|
Should be used only stylistically, rather than to, say, capitalize proper nouns. Example:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| text-align | left
center right justify |
Determined by browser | Block-level elements | Yes | |
|
Applied to block-level elements (p, h1, etc.) to align a block of text. Replaces the HTML "align" attribute on paragraphs, headings, and divisions. Examples:
|
|||||
|
|
|||||
| Box Properties | |||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| border | <border-width>
<border-style> <border-color> |
Not defined | All elements | No | |
|
Creates a border of 1 to 4 sides. Shorthand for border-top, border-right, border-bottom, border-left.
Examples:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| margin | <length>
<percentage> auto |
Not defined | All elements | No | |
|
Sets the margins of an element (space around an element) by specifying between one and four values (margin-top, margin-right, margin-bottom, margin-left), where each value is a length, a percentage, or auto. Percentage values refer to the parent element's width. Negative margins are permitted. Examples:
|
|||||
|
|
|||||
| Property | Possible Values | Initial Value | Applies to: | Inherited? | |
| padding | <length>
<percentage> |
0 | All elements | No | |
|
Shorthand for padding-top, padding-right, padding-bottom, and padding-left. An element's padding is the amount of space between the border and the content of the element; up to four values may be specified; each value is either a length or a percentage. Percentage values refer to the parent element's width. Negative values are not permitted. Examples:
|
|||||
1501 Kincaid Street, Eugene, OR 97403-1299 | T: (541) 346-3053 | F: (541) 346-3485
