CSS Declaration

Style rules in a linked or embedded style sheet are written in the same way. The thing we are influencing – the selector – opens the rule. At the simplest level, the selector is simply an element that we wish to change the appearance of universally, but we will encounter variations on this very shortly. Following the selector, and inside curly braces, is the style declaration: a set of style rules, written as property and value pairs, with colons between each. A semi-colon is placed after each value to separate it from the next rule in the declaration.

Inline styles use the same declaration format, but make the rules the value of a style attribute of an element:

<p style="color: red; font-size: larger;">

As a general rule, CSS is insensitive to spaces and carriage returns. This is equally valid in a linked, embedded, or scoped stylesheet:

p {
	color: red;
	font-size: larger;

It's also possible to remove spaces and quotes from inline style declarations, although this tends to reduce readability:

<p style=color:red;font-size:larger>

Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.