The CSS syntax contains the selector and the declaration block, which will be clearer with the following example:

CSS Syntax

Selector: A CSS selector specifies the HTML tag we wish to style. A selector can be any element such as <title>, and <h1>.

Declaration Block: This block can consist of more than one declaration that is isolated by the semicolon. Here, there are two types of declarations for the example as mentioned above:

  • Color: red;
  • Font-size: 12px;

 All the declarations include the property name and the value that are isolated by the colon.

Property: It is a part of the HTML element’s attributes. A property could be any color or border.

Value: CSS properties are required to be assigned by some values. Thus, values are provided to the properties of CSS. Value “red” is given to the color property in the example, as mentioned above.

Example:

Explanation of above Example:

  • P is the selector.
  • Color is the property.
  • The value of the property is green.
  • Another property is text-align.
  • The value of the property is left.

Pin It on Pinterest

Share This