CSS ClassesUsing classes with your CSS can make customizing your pages ten times easier, because you can give different occurances of the same element different styles. Say you wanted every cell of a table to have a different color and font, like this:
Instead of defining everything with HTML, we use CSS classes. Here is the code:
<table border="1"><tr> <td class="pink">pink</td> <td class="green">green</td> </tr><tr> <td class="yellow">yellow</td> <td class="blue">blue</td> </tr></table> Then, in your header, you'd define what happens with each different class, like so:
<style type="text/css"><!-- .pink {FONT-FAMILY: Times New Roman,Times; BACKGROUND: #FFCCFF} .green {FONT-FAMILY: Courier New,Courier; BACKGROUND: #33FFCC} .blue {FONT-FAMILY: Verdana; BACKGROUND: #00CCFF} .yellow {FONT-FAMILY: Arial,Helvetica; BACKGROUND: #FFFF66} --></style> Now everything you add class="pink" to will have a pink background color and Times New Roman font.
This can also be useful if you want different links to look different ways. For example, links in the menu to look one way, and links in the body/text to be different. In the style sheet of your page you'd usually have this:
a:active {color:pink} a:visited {color:pink} a:link {color:pink} a:hover {color:blue} If you had a few links you wanted to be a bit different, you'd add this:
a.menu:active {color:blue} a.menu:visited {color:blue} a.menu:link {color:blue} a.menu:hover {color:pink} Then add class="menu" to the links you'd like different, like this:
<a href="page.html" class="menu">link</a>
CSS Border style valuesCSS Border Styles<div style="border-style: solid; "> The border is a single line segment. <div style="border-style: dashed; "> The border is a series of short line segments. <div style="border-style: dotted; "> The border is a series of dots. <div style="border-style: double; "> The border is two solid lines. <div style="border-style: groove; "> The border looks as though it were carved into the canvas. <div style="border-style: inset; "> The border makes the entire box look as though it were embedded in the canvas. <div style="border-style: none; "> No border. This value forces the value of 'border-width' to be '0'. <div style="border-style: outset; "> The opposite of 'inset': the border makes the entire box look as though it were coming out of the canvas. <div style="border-style: ridge; "> The opposite of 'groove': the border looks as though it were coming out of the canvas.
The future CSS3 border styles<div style="border-style: dot-dash;"> Alternating dots and dashes. <div style="border-style: dot-dot-dash;"> Two dots and a dash. <div style="border-style: wave;"> A wavy line.
|