CSS Syntax

Like HTML and other computer languages, CSS Syntax also written to CSS Rule. Through which CSS Declarations written for the HTML document.

css syntax

CSS Syntax also called Style Rule. The Style Rule consists mainly of two parts. You can see them in the image above.

  • CSS Selectors
  • CSS Declaration

CSS Selectors

A Selector is the word / word group / letter for which ‘Style Rule’ written. It written outside of ‘Curly Bracket’. This is usually ‘HTML Tag’. But, it can be written by giving any name. Click to know more about CSS Selectors.

CSS Declaration

Declaration is the part of the Style Rule in which Style announced for a selector. It also has two parts.

  1. Property – Property Style is the part of Rule that Style we want to apply to a ‘Selector’. It written within the curly bracket. It may assume the attribute of the HTML tag.
  2. Value – The third part of the Style Rule is Value. It also written within the Curly Bracket. Value is set for the property in it. The “Value” of the Property Selector called “how”.

Example

<!DOCTYPE html>
<html>
<head>
<style>
p {
  color: green;
  text-align: center;
} 
</style>
</head>
<body>

<p>Hi, This is an Example</p>
<p>These paragraphs are styled with CSS.</p>

</body>
</html>