Starting to Code CSS

News Feed

Starting to Code

CSS style sheets are written like this.

selector {
property : value ;
}

Lets break that down. The first part is the selector, it selects what element the style rule (the part in the {}) gets applied to. Here are a few examples

body {
property : value ;
}
.my_class {
property : value ;
}
#my_id {
property : value ;
}

The first example would set the rule to apply to the body element.

The second would apply to any element with attribute class="my_class", you can set "my_class" to any value you like.

The third will apply to the element with attribute id="my_id" on it. This is much like the class but there can only be one element with a particular id in any one document.