Css/Training/Syntax

From W3C Wiki
< Css‎ | Training

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.


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.