What Is CSS?

CSS, or Cascading Style Sheets, is the language used to describe the presentation of HTML documents. HTML provides structure while CSS controls appearance, spacing, positioning, typography, colors, responsive behavior, and visual effects.

CSS is not a programming language in the traditional sense. It is a declarative styling language: you describe the visual result you want and the browser determines how to render it.

A CSS rule normally contains a selector and a declaration block. The selector determines which elements are targeted, while declarations define the styles applied to those elements.

The browser does not simply read CSS from top to bottom. It resolves competing declarations using the cascade, specificity, source order, inheritance, and importance.

Think in layers

HTML describes what an element is, CSS describes how it should look and behave visually, and JavaScript generally handles application behavior and interaction.

HTML → CSS → Rendered Page
A Basic CSS Rule
p {
  color: #2563eb;
  font-size: 18px;
  line-height: 1.6;
}
💡 The selector p targets paragraph elements. Each declaration consists of a property and value.
Key Takeaways
  • CSS controls presentation and visual layout.
  • A CSS rule consists of a selector and declarations.
  • The browser resolves conflicting rules through the cascade.
Knowledge Check

What is the primary purpose of CSS?