CSS/Training/Syntax

From W3C Wiki
< CSS‎ | Training
Revision as of 16:05, 15 March 2011 by Hiroki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Syntax

CSS has some syntax. The point of the syntax of CSS is described as follows.

Point of the syntax

This syntax has two parts, the selector and the declaration.

Csssyntax.png


Selector: Specifies the target of styling.
Declaration: Specifies the property and value.

  • Declaration is contained between "{" ... "}".
  • Declaration end with a semicolon.
p{ color: red; }

Declaration part can have one or more declarations.

p{ color: red; font-size: 12px; }

When the declarative part has a lot of declarations, the Web creators usually describes it as follows:

p{
  color: red;
  font-size: 12px;
}

Describing it like this is more comprehensible.


CSS comments

  • CSS comment starts with "/*", and end with "*/".
 p{
   color: red;
   /* This is a comment */
   font-size: 12px;
 }


In the next chapter, you will learn the selectors.