-style, -width, -color
dotted, dashed, solid, double, groove, ridge, inset, outset
thin, thick, medium
The -color properties can be any color specification.
border-style: solid; border-width: thin; border-color: black;It is common practice to simplify this construction using the border property with which we can specify all three values in one declaration:
border: solid thin black;Analogously, this group of declarations:
border-left-style: solid; border-left-width: thin; border-left-color: black;is equivalent to this one declaration
border-left: solid thin black;The border-width can be used to specify the width on all four sides clockwise from the top, such as this:
border-width: 1px 2px 3px 4px;is equivalent to the four specifications:
border-top-width: 1px; border-right-width: 2px; border-bottom-width: 3px; border-left-width: 4px;Here are some examples
<div style="border: solid thin black; width:200px"> Here is my text. </div>
<div style="border-style: ridge; border-color: red; border-width: 0px 0px 8px 4px"> Here is my text. </div>
<img src="small-butterfly.jpg" style="border: groove 5px #CC6600" />
table.redlines { border: solid 1px red; }
table.redlines td {
border: solid 1px red;
padding: 10px;
}
When applied to this table:
<table class="redlines"> <tr><td colspan="2">A</td></tr> <tr> <td>B</td> <td>C</td> </tr> </table>we get this result:
| A | |
| B | C |
<table cellspacing="0" class="redlines"> <tr><td colspan="2">A</td></tr> <tr> <td>B</td> <td>C</td> </tr> </table>yields the result:
| A | |
| B | C |
table.redlines1 {
border-top: solid 1px red;
border-right: solid 1px red;
}
table.redlines1 td {
border-left: solid 1px red;
border-bottom: solid 1px red;
padding: 10px;
}
When applied to this table:
<table cellspacing="0" class="redlines1"> <tr><td colspan="2">A</td></tr> <tr> <td>B</td> <td>C</td> </tr> </table>we get this result:
| A | |
| B | C |
The color and background-color properties create the appearance for the foreground content (e.g., the text) and background color layers, respectively.
In addition to background colors, background images are common. Some consider them superior to background colors because it give the page a textured as opposed to flat appearance. Background images are typically repeatable in that adjacent copies of the image appear to be somehow extending the full image.background-image: url( GRAPHICS_FILE_OR_HYPERLINK_TO_ONE );
<h3>Hello There</h3> <hr />Here are some variations of background image usage:
body {
color: red;
background-color: #cc33ff;
}
This style rule
would create the following effect.
A typical thing to do is to repeat the background image over the entire page, thus covering up the background color, if any. Suppose we use modify the body rule, adding a new property:![]()
body {
color: red;
background-color: #cc33ff;
background-image: url( 'paper.gif' ); /* quotes not necessary here */
}
This would create the
following effect.
The image is repeated both horizontally (repeat-x)
and vertically (repeat-y) thereby completely covering
up the background color.
It is mentioned that the quotes aren't really necessary. The only time
they are necessary is if the file name you're referencing has embedded
blanks.
body {
color: red;
background-color: #cc33ff;
background-image: url( 'paper.gif' );
background-repeat: repeat-y;
}
This would create the
following effect.
body {
color: red;
background-color: #cc33ff;
background-image: url( 'obnoxious-reminder.gif' );
background-repeat: no-repeat;
background-position: top right;
}
This would create the
following effect.
body {
color: red;
background-color: #cc33ff;
background-image: url( 'obnoxious-reminder.gif' );
background-repeat: no-repeat;
background-position: top right;
background-attachment: fixed;
}
This would create the
following effect.
Scroll the document vertically to see the difference
between this one and the previous one.
.paperbg { background-image: url( 'paper.gif' ); }
.padd5 { padding: 5px; }
applied to
Here's a <span class="paperbg padd5">span with paper background</span> and <p class="paperbg padd5" style="width:100px"> an entire paragraph with paper background </p>we get:
an entire paragraph with paper background
div.matwith {
padding: 20px;
width: 120px; /* must be target image width */
border: groove 5px #CC6600;
}
and apply this and the above to the HTML element:
<div class="matwith paperbg"><img src="small-butterfly.jpg" /></div>We get this result

Here is an example of an image <img style="margin:20px" src="small-butterfly.jpg" /> integrated into text. If we try the same thing with <span style="margin:20px;background-color:yellow">THIS SPAN</span> we see that the margins are rendered differently.It is rendered as follows:
integrated into text. If we try the same thing with
THIS SPAN
we see that the margins are rendered differently.
A floating box is an HTML element which
integrates within surrounding
text by allowing the surrounding text to wrap around it.
The style property is this:
<img style="float:right" src="small-butterfly.jpg" />Observe what happens when you resize the browser. Additionally, one can use the style property
element:pseudo-class { ... }
.class_name:pseudo-class { ... }
element.class_name:pseudo-class { ... }
:pseudo-class { ... }
These pseudo-class properties are few and quite specific. They are
used to specify properties of the element which
are dependent not just on the content of
the element, but the state of the browser
(such as its width, mouse position, etc.)
It's easiest to understand through the examples.
a:link { color: green; text-decoration: none; }
a:visited { color: blue; text-decoration: none; }
a:hover { text-decoration: underline; color: magenta; }
To restrict the behavior to only certain specified hyperlinks, we
would combine the class specification like this:
a.special:link { color: green; text-decoration: none; }
a.special:visited { color: blue; text-decoration: none; }
a.special:hover { text-decoration: underline; color: magenta; }
When these latter rules are applied to the hyperlink:
<a class="special" href="http://www.yahoo.com">Yahoo</a>the result is this: If you use the background-color as a variation, you can create simple rollover-like effects with these psuedo-class properties. For example, given these rule specifications:
a.rollover {
text-decoration: none;
color: white;
background-color: red;
border: solid 4px yellow;
padding: 2px 8px 2px 8px;
}
a.rollover:hover {
text-decoration: none;
color: white;
background-color: black;
border-color: purple;
}
applied to:
<a class="rollover" href="http://www.yahoo.com">Yahoo</a>the effect is this: You can't get too carried away with this construction for a number of reasons. Ultimately, the results are more consistent if you create button-like hyperlinks with images.
p.special:first-letter { font-weight: bold; font-size: 200% }
p.intro:first-line { text-transform: uppercase; }
Then the following HTML code
<p class="special"> Long ago and far away, there lived a young man ... </p> <p class="intro"> The main point about this lecture is to understand how to use the Cascading Style Sheets. The syntax of these is relatively simple, but they can be used to make many different changes. </p>would look like this:
Long ago and far away, there lived a young man ...
The main point about this lecture is to understand how to use the Cascading Style Sheets. The syntax of these is relatively simple, but they can be used to make many different changes.
When you use block-level elements the browser normally lays them out with respect to the current position of the text. This is called the normal flow. Floating boxes are an example of elements which don't exactly follow this rule.
We can explicitly control the positioning feature of elements with the position property whose values are thesediv.box {
position: absolute;
width: 150px; height: 150px;
border: solid thin black;
}
div.yellow {
background-color: yellow;
top: 50px; left: 50px;
}
div.blue {
background-color: blue;
top: 100px; left: 100px;
}
div.title {
position: absolute;
top: 110px; left: 20px;
color: magenta;
font-weight: bold;
font-size: 300%;
}
And they are used like this:
<div class="yellow box"></div> <div class="blue box"></div> <div class="title">This is my title</div>with the following resulting web page. With absolute positioning one is able to create overlapping boxes. In this case the overlap order is determined by the order in which the boxes appear in the HTML document. However, if we place the boxes are generated in a different order like this:
<div class="title">This is my title</div> <div class="blue box"></div> <div class="yellow box"></div>we get the following resulting web page.
<div class="title" style="z-index:2">This is my title</div> <div class="blue box" style="z-index:1"></div> <div class="yellow box" style="z-index:0"></div>as can be seen in the following resulting web page.
none, disc, circle, square, decimal, decimal-leading-zero, lower-alpha, upper-alpha, lower-roman, upper-roman, lower-latin, upper-latin, ... (other less common language choices)When this style property is used the choice of ol or ul is irrelevant
It has been mentioned that the attributes type and start attributes can be used to control the marker symbol. Both of these are considered deprecated but I know of no way to set the start value for ordered lists using style properties.
Here are some examples:<ol style="list-style-type: square"> <li>x</li> <li>y</li> <li>z</li> </ol>
<ol style="list-style-type: lower-alpha"> <li>xxx</li> <li>yyy</li> <li>zzz</li> </ol>
<ol style="list-style-type: upper-roman" start="3"> <li>xxx</li> <li>yyy</li> <li>zzz</li> </ol>
outside, inside, inheritHere is a simple example:
List 1: the default value of <tt>list-style-position</tt> is <tt>outside</tt>:
<ol>
<li>I have to generate at least<br />
two lines for you to see the effect
</li>
<li>something else</li>
</ol>
List 2: here we use the value <tt>inside</tt>:
<ol style="list-style-position: inside">
<li>I have to generate at least<br />
two lines for you to see the effect
</li>
<li>something else</li>
</ol>
which has this appearance:
<ul style="list-style-image: url(blueballdot.gif)"> <li>xxx</li> <li>yyy</li> <li>zzz</li> </ul>Its appearance is this: