CSS Syntex:-

A CSS rule consists of a selector and a declaration block.

h1 {color:red;  font-size:20px;}

In the above statement, h1 is a selector. 

{color: red;} this is a declaration in this color is the property and the red is the value of the color.

{font-size:20px;} this is also a declaration in this font size is a property and the 20px is the value of the font size. 

The selector point of the HTML element you want to style.

Declaration blocks contain one or more declarations separated by semicolons.

 Each declaration includes a CSS property name and value, separated by a colon.

Multiple CSS declarations are separated with semicolons, and declaration blocks are surrounded with curly braces.


<!DOCTYPE html>

<html>

<head>

p{color: red;

text-align: center;

 }

</head>

<body>

<p> This is a paragraph.</p>

<p> This is also a paragraph in which we will use CSS color and text alignment.</p>

</body>

</html>

Try this code for a better experience 


Example Explained:-

  • In the above code, p is a selector in CSS (it points to the HTML you want to style <p>).
  • Color is the property, and red is the value of the property.
  • Text align is the property, and the center is the value of the property.