Introduction to CSS
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
styleattribute on one element (avoid for real work). - Internal — a
<style>block in the<head>. - External — a separate
.cssfile 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?
Is CSS a programming language?
Where do I put my CSS file?
<head> with <link rel="stylesheet">.