Basic CSS Syntax: Property Syntax

Style sheet properties are divided into two parts:

  1. property name, and
  2. value.

The property name and the value are separated by a colon (:). The entire property ends with a semi-colon (;).

Generic Example:

property-name:value;

Actual Example (setting the font-size property to be 24 point):

font-size:24pt;

Note: A property name NEVER has any spaces in it. An individual value NEVER has any spaces in it. There MAY be a space after the colon, but it is not recommended.

The following example is acceptable:

font-size: 24pt;

In the above example, I have placed a space after the colon between the property name and value; this is permissible (but, again, not recommended).

The following example is WRONG:

font size:24pt;

In the above example, I have placed a space in the property name; this is illegal and will cause your CSS to break. The actual property name is "font-size", not "font size".

The following example is also WRONG:

font-size:24 pt;

In the above example, I have placed a space between the number and the type of measurement unit in the value of the property definition; this is illegal, and will cause your CSS to break. The actual value is "24pt", NOT "24 pt" (which means something COMPLETELY different in CSS).

As you can probably already tell, CSS is MUCH more particular about syntax variations than regular HTML. You must be extremely careful with your syntax in CSS, or your CSS will fail to operate.

You will also notice that there are NO equals signs (=) or quote marks ("") in CSS. Although we are dealing with CSS properties for tags which have some parallels in HTML attribute syntax, the actual syntax constructs are completely different. CSS IS NOT HTML!

Main Menu