Introduction to CSS

Uploaded : 4 months ago Updated : 4 months ago beginner

Take The Quiz

Take The Quiz

What is CSS?

CSS (Cascading Style Sheets) is the language that styles web pages. HTML provides the structure; CSS decides how it looks — colours, fonts, spacing and layout.

How a CSS rule is built

A rule targets elements with a selector, then lists declarations (property: value) inside braces.

h1 {
  color: #1685bc;
  font-size: 2rem;
}

Three ways to add CSS

  • Inline — a style attribute on one element (avoid for real work).
  • Internal — a <style> block in the <head>.
  • External — a separate .css file linked with <link> (recommended).
<link rel="stylesheet" href="styles.css">

Prefer an external stylesheet

One .css file shared across pages keeps your styling consistent and easy to change in a single place.

The cascade & specificity

When several rules target the same element, CSS picks the winner by specificity then order: an id beats a class, a class beats a tag; if specificity ties, the later rule wins.

Avoid overusing !important

It overrides the normal cascade and makes styles hard to debug. Reach for a better selector first.

Frequently asked questions

What does “cascading” mean?
Styles cascade: several sources (browser, external, internal, inline) combine, and rules can override each other by specificity and order.
Is CSS a programming language?
No — like HTML it is declarative. Modern CSS has variables and functions, but no general logic.
Where do I put my CSS file?
Anywhere reachable by the page; link it in the <head> with <link rel="stylesheet">.

Ready for more?

Next, learn the core CSS properties you’ll use to style any page.

Continue to CSS Fundamentals

Comments