| Writing and doing a CSS subclass is pretty straight-forward.
For those of you who don't know what a sub-class is let me explain.
In programming a class is an object that contains properties, attributes,
and values. For example, the object of a house contains a kitchen,
a bathroom, a bedroom or two, and maybe a basement or attic. A sub-class
could be a den in which the den is a cross between a livingroom
and an office.
With CSS you can create unlimited numbers of sub-classes. For instance
let's say I have a news bulletin box and I want to text inside that
to be bolded in a light red color. I can create a CSS sub-class
for the paragraph HTML tag shown below to do just that.
(<p>some text</p>) Here's the CSS sub-class:
| p.newsbulletin { |
font-family: Arial, Helvetica, Sans-Serif ; |
| |
font-weight: bold; |
| |
color: red;} |
- Note the period. The period is used in CSS to denote
a sub-class.
- Also note the curly braces. These contain the "attributes"
of the sub-class. Just like your house has various rooms, those
rooms contain certain characteristics. Eg: blue painted walls.
Every CSS element must
have an opening bracket and a closing bracket.
- Lastly, note the semi-colon that is placed after each paragraph
attribute. The semi-colon tells the CSS interpreter to literally
end the attribute.
Here's the sub-class in action:
Newsletter Bulletin: CSS sub-classes finally added to website!
|