CSS Syntax

The CSS stylesheet defines the rules that web browsers comprehend to apply formatting effects on the respective elements.

The CSS rule has two parts: a selector and a declaration (block).

The selector represents the elements in the HTML document to which the CSS rule will be applied. The declaration defines how the elements would be displayed on the webpage.

A declaration contains a property and a value which are separated by a colon (:) and terminates with a semicolon (;).  Curly braces are used to enclose declaration blocks.

The property refers to the styling attribute that you want to modify. For example: color, background, and font. Every property has a value such as size could be 12 or 14.

Example

.css
h2 {
color: red;
text-align: right;
}

 

Here  h2 is the selector, color and text-align are the CSS properties with red and right as their respective values.

Case Sensitivity in CSS

The CSS attribute names and values are not case-sensitive. However, CSS selectors are case-sensitive. This means .maincontent differs from .mainContent.