Skip to content

Cascading Style Sheets (CSS)

CSS, short for Cascading Style Sheets, is a declarative style sheet language that describes how documents written in a markup language such as HTML are presented on screen, in print, and in other media.

A style sheet is a set of rules. Each rule pairs a selector, which picks out the elements to affect, with a declaration block of property and value pairs that set their appearance. A rule describes the desired result, not the steps to reach it, and the rendering engine decides how to apply it.

The word cascading names how CSS resolves conflicts when several rules style the same element. It settles each property on a single value by weighing three factors:

  • Origin: A rule may come from the browser’s defaults, the user’s settings, or the page author, and author rules normally win.
  • Specificity: A more precise selector overrides a more general one that sets the same property.
  • Order: When two rules carry equal weight, the one declared later wins.

To see these factors decide a single property, set the origin, specificity, and source order of two competing rules below and watch which one wins and why:

Interactive diagram — enable JavaScript to view.

Many properties also inherit, so an element can take a value from its parent unless a rule sets it explicitly.

CSS is a web standard maintained by the W3C and built from independent modules that advance separately rather than as numbered versions. Separating presentation from the content and structure that a markup language provides is its defining purpose, which keeps styling reusable across many documents.

HTML and CSS for Python Developers

Tutorial

HTML and CSS for Python Developers

There's no way around HTML and CSS when you want to build web apps. Even if you're not aiming to become a web developer, knowing the basics of HTML and CSS will help you understand the Web better. In this tutorial, you'll get an introduction to HTML and CSS for Python programmers.

basics django flask front-end web-dev

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated Aug. 17, 2026