Attributes and Values

From csszoo
(Redirected from Attributes and values)
Jump to: navigation, search

CSS commands take the form of pairs of attributes and values.

Here is a simple example:

  color: blue;

This command applies to all the div elements in the document. It starts with the relevant attribute (or property), in this case the colour (the American spelling is used), then a colon (:), followed by the value for the attribute - in this case blue. This will make the type (or 'font') in all the divs of the document blue (the colour of the background and border can be changed using other attributes).

Here is a longer example, with several attribute-value pairs which affect the appearance of the letters (or font) in the paragraph (= p) elements:

  font-family: sans-serif;
  font-size: 12pt;
  font-weight: bold;
  font-style: italic;

Each rule here ends with a semi-colon (;). This may be optional if there is only one rule or it is the last rule in the list. However, missing out the semi-colon if there is another rule following means both rules will not work. It is therefore safest always to end each rule with a semi-colon.

Note also the hyphen (-) separating the two words in the attributes. Attributes can't have spaces in them (otherwise the computer would expect a colon next), so multiple-word attributes have to be joined up like this.