CSS Tutorial : Misc Topics
A few miscelleanous topics.
You may have noticed that some of the examples I've had has used comments. This makes the style sheets easier to read by others. Also you can define exactly what that class name is and is used for.
The comment delimiters are similar to C and Java style comments using the /* and */ to start and stop comments.
Example:
.bg1 { background-color: #EEEEEE; }
A nice thing about style sheets is that types can inherit certain properties by their parent object. Sound confusing, its not. One of the common inheritance features in standard HTML is the UL and LI tag (on some browsers).
When a LI tag is used inside of an UL tag, the list bullet is smaller. The LI tag changes due to its surrondings, specifically inside a UL tag.
To do this in CSS is rather easy. In this example I'll make the LI text smaller when it is inside a UL tag.
Example:
That's all there's to it. Now every LI tag used will be 80% smaller when it is inside a UL tag.
Two properties that go together like chocolate and peanut-butter are float and clear. Float allows an object to float in its space relative to the other objects around it. I used this on the introduction page in the benefits section. You can use float to produce drop caps and other nice effects. Clear is used to stop a float. AN example will help.
The valid values for float are none, left, and right. The valid values for clear are none, left, right and both.
Example:
.nomore { clear: left; }
Apply your style to style sheets. Experiment and see what you can do with this new tool. Read up, look at examples, be creative, and original.
There are numerous properties I did not mention, most are as straight forward as the rest of the properties. Some of these are padding, display, white-space, list style (you can make your LI's images), and borders. For a complete listing of properties see the quick reference guide or the W3C's recommendation paper.