Introduction to CSS

Introduction to CSS


CSS Syntax

The syntax of CSS consists of a selector and a declaration block. A typical CSS rule looks like this:

selector {
  property: value;
}

For example:

h1 {
  color: blue;
}

This CSS rule will turn all <h1> elements blue.


Cascading

Cascading refers to the order in which CSS rules are applied to elements. CSS follows a set of rules to determine which styles to apply when multiple rules target the same element. The key factors in cascading are:

Note: CSS code is written in a key-value pair format. The key represents the property, and the value defines the style applied to the selected element.