CSS Tutorial · CSS Basics · Lesson 1 of 19
CSS Introduction
What CSS is, how rules work and how it separates style from content.
What is CSS?
CSS (Cascading Style Sheets) describes how HTML elements are displayed: colours, fonts, spacing, layout, animation, and how the page adapts to phones and large screens. One stylesheet can style an entire website.
A CSS rule
h1 {
color: navy;
font-size: 32px;
}
h1is the selector — which elements to style.color: navy;is a declaration: a property and a value.- Declarations go inside
{ }and end with;.
Press Run to see the CSS applied:
<style>
body { font-family: system-ui, sans-serif; background: #f8fafc; }
h1 { color: #1e3a8a; font-size: 28px; }
p { color: #334155; line-height: 1.6; }
</style>
<h1>Styled with CSS</h1>
<p>The same HTML can look completely different with another stylesheet.</p>
New to HTML? Start with the HTML tutorial.
Test yourself
In p { color: red; }, what is p?
The propertyThe valueThe selectorThe declaration
Show answer
Answer: The selector