Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 139 ยท Getting Started

What Is CSS?

Discover what CSS is, how browsers apply it to HTML, and what rules, selectors and declarations look like. Style your first page and see what the course covers.

Welcome to the CSS course! Every website you have ever admired, from a calm reading app to a bold product page, owes its look to CSS. HTML gives a page its structure and meaning: this is a heading, this is a list, this is a button. CSS decides how all of it looks: colors, fonts, spacing, layout, and even animation.

CSS stands for Cascading Style Sheets. That sounds technical, but the core idea is simple. You write short rules that say "find these elements and make them look like this", and the browser applies them for you. By the end of this lesson you will have written several of those rules and seen them change a page live. By the end of the course you will be able to build complete, responsive, accessible layouts from scratch.

You don't need to know any CSS yet. You should know basic HTML (elements, attributes and how a page is structured). If that feels shaky, the HTML course has you covered.

What CSS does

Open any page with CSS turned off and you get plain black text on a white background, stacked from top to bottom, with blue underlined links. That is the browser's built-in default look. It is readable, but it is not a design.

CSS lets you change almost everything about that default:

  • Color and typography: text color, backgrounds, fonts, sizes and line spacing.
  • Spacing and boxes: the space inside and around elements, borders, rounded corners and shadows.
  • Layout: placing elements side by side, in columns or in grids, and adapting them to phones, tablets and wide screens.
  • Interaction and motion: hover effects, focus styles, transitions and animations.

The crucial point is that CSS changes the presentation, not the content. The same HTML can look completely different with a different stylesheet. That separation is what lets a site redesign its whole look without rewriting a single page.

Your first styled page

Here is a small page with no styling except the browser defaults. Press Run (or just edit the code) and look at the preview.

Unstyled HTML

Now the same HTML with a <style> block on top. The markup has not changed at all; only the CSS is new.

The same page, styled

Try changing #2f6b3a to crimson, or 24px to 60px, and watch the preview update. Experimenting like this is the fastest way to learn CSS, and every lesson in this course gives you a live editor for exactly that reason.

How a CSS rule is built

Every piece of styling in the example above is a rule. Let's take one apart:

CSS
h1 {
  color: #2f6b3a;
  font-size: 2.2rem;
}
  • h1 is the selector. It picks which elements the rule applies to: here, every <h1> on the page.
  • The curly braces hold the declaration block.
  • color: #2f6b3a; is a declaration. It pairs a property (color, what to change) with a value (#2f6b3a, what to change it to), separated by a colon and ended with a semicolon.

That is the whole grammar of everyday CSS: selector, then braces, then property-value pairs. Selectors can get very clever and there are hundreds of properties, but they all fit into this shape. You will study the details in CSS Syntax.

Read rules out loud. h1 { color: green; } reads as "for every h1, set the color to green". If a rule doesn't make sense as a sentence, something is probably missing.

How the browser applies CSS

When a browser loads a page, it does roughly this:

  1. Reads the HTML and builds a tree of elements, the DOM.
  2. Reads the CSS from every source: its own defaults, any linked stylesheets, <style> blocks and style attributes.
  3. Matches rules to elements. For each element, it finds every rule whose selector matches it.
  4. Resolves conflicts. If two rules set the same property on the same element, the browser follows a set of priorities called the cascade to pick a winner. That is the "Cascading" in the name.
  5. Computes the final values, lays out the boxes and paints the result on screen.

This happens again whenever something changes, for example when you hover a link or resize the window. You never tell the browser when to apply a rule; you only describe what should be true, and the browser keeps it true.

Two rules, one element

The second paragraph matches both p and .warning. Both set color, so the browser has to choose. The class selector is more specific, so dark red wins. The font-size from the first rule still applies, because nothing overrides it. Rules don't replace each other wholesale; they combine, property by property. That idea runs through everything you will learn, and the chapter on the cascade explains it fully.

Why CSS is worth learning well

Many developers learn just enough CSS to get by and then fight it for years. Rules seem to be ignored, layouts break on phones, and a fix in one place breaks something elsewhere. Almost all of that pain comes from a few misunderstood ideas: the cascade, the box model and how layout works.

Modern CSS is also far more capable than its reputation. Things that once needed JavaScript or hacks are now a few lines: centering with Flexbox, whole page layouts with Grid, theming with custom properties, components that adapt to their container with container queries, and smooth animations. Learn the foundations properly and these features feel natural instead of magical.

What this course covers

The course is organized into chapters that build on each other:

  • Getting Started and Selectors: how to add CSS to a page, its syntax, DevTools, and every way to select elements.
  • The Cascade: why one rule beats another, specificity, inheritance and cascade layers.
  • Values, Units and the Box Model: units, colors, and how boxes are sized.
  • Text, Backgrounds and Effects: fonts, gradients, shadows, filters and more.
  • Layout: positioning, Flexbox, Grid and responsive design.
  • Animation and Modern CSS: transitions, keyframes, nesting and newer features, each with honest notes about browser support.
  • Best practices and projects: dark mode, accessibility, organizing CSS, and four complete projects that tie it all together.

Each lesson ends with a short quiz. Quizzes are not graded; they are there to help you notice what stuck and what deserves a second look.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is CSS mainly responsible for?

    HTML gives structure and meaning; CSS controls presentation such as colors, fonts, spacing and layout.
  2. 2. In the rule p { color: navy; }, what is color?

    color is the property (what to change), navy is the value, and p is the selector that picks the elements.
  3. 3. Two rules set different color values on the same element. What happens?

    Conflicts are normal in CSS. The cascade picks a winner using priorities such as specificity and source order.
  4. 4. One rule sets color and font-size on a paragraph; a more specific rule sets only color. Which font-size does the paragraph get?

    Rules combine property by property. The second rule only wins for color, so the first rule's font-size still applies.

Summary

  • CSS (Cascading Style Sheets) controls how HTML looks: color, type, spacing, layout and motion.
  • It changes presentation, not content, so the same HTML can wear many designs.
  • A rule is a selector plus a declaration block of property: value; pairs.
  • The browser matches rules to elements, resolves conflicts with the cascade, then lays out and paints the page.
  • Rules combine property by property; a winning rule only overrides the properties it sets.

Next: Adding CSS to a Page, where you learn the three ways to connect CSS to your HTML and when to use each.