CSS Tutorial

CSS Syntax


A declaration block and a selector make up a CSS rule.


CSS Syntax

CSS Syntax -

The HTML element you wish to style is indicated by the selector.

One or more declarations are contained in the declaration block and are divided by semicolons.

A colon (:) separates the name of the CSS property from its value in each declaration.

Semicolons are used to divide CSS declarations, and curly braces are used to enclose declaration blocks.

Example

In this example all <p> elements will be center-aligned, with a blue text color:

				
					p {
  color: red;
  text-align: center;
}
				
			

Example Explained

  • In CSS, p is a selector that points to the <p> HTML element that you wish to style.
  • Red is the value of a color, which is a property.
  • The property value is center, and the property is text-align.
Share this Doc

CSS Syntax

Or copy link

Explore Topic