CSS Introduction

What is CSS?

CSS stands for Cascading Style Sheets. It is a language designed to simplify the process of making web pages presentable. It describes how HTML elements are to be displayed on screen, paper, or in other media. CSS saves a lot of work — it can control the layout of multiple web pages all at once.


Understanding Cascading

Cascading in CSS defines how the browser resolves conflicts between multiple CSS rules using importance, specificity, and source order.


CSS Selectors

A CSS selector is a pattern used to target HTML elements and apply specific styles based on their type, class, ID, attributes, or state.


Working of CSS

CSS applies styles to HTML elements, helping the browser render a visually styled and well-structured web page.

1. Load HTML

The browser fetches the HTML document from the server.

2. Parse HTML

The browser analyzes HTML syntax and breaks it into meaningful tokens.

3. Build DOM (Document Object Model)

The browser creates a tree structure representing all HTML elements.

4. Load CSS

The browser downloads CSS files referenced in the HTML.

5. Parse CSS

The browser converts CSS into a structured CSS Object Model (CSSOM).

6. Compute Styles (Match + Cascade)

The browser determines the final styles for each element based on CSS rules.

7. Build Render Tree

The browser combines DOM and CSSOM to prepare visible elements for rendering.

8. Layout (Reflow)

The browser calculates the size and position of each visible element.

9. Paint

The browser draws visual parts like text, colors, and images onto the screen.

10. Display (Compositing)

The browser merges all painted layers and displays the final page output.


Advantages of CSS


Exercise

?

What does CSS stand for?