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:
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.
Related Resources
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.
For additional information on related topics, take a look at the following resources:
- HTML and CSS Foundations for Python Developers (Course)
- Build and Submit HTML Forms With Django – Part 4 (Tutorial)
- How to Serve a Website With FastAPI Using HTML and Jinja2 (Tutorial)
- Web Scraping With Beautiful Soup and Python (Course)
- How to Serve a Website With FastAPI Using HTML and Jinja2 (Quiz)
By Martin Breuss • Updated Aug. 17, 2026