Learn HTML & CSS – tutorial, cheatsheet & exercises
HTML and CSS are the foundation of every web page. HTML describes the structure and meaning of content (headings, paragraphs, forms, tables), CSS controls the appearance (colors, spacing, layout, animations). Both are declarative: you describe what is there and how it should look – the browser does the rest.
All you need is an editor and a browser. That makes HTML/CSS the perfect entry into programming – and, for experienced developers, a field with plenty of depth: modern layouts with Flexbox and Grid, responsive design, CSS variables, animations and accessibility. In this course all examples run directly in the browser: click "Run" and change the code.
Hello World in HTML & CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello World</title>
</head>
<body>
<h1>Hello World!</h1>
<p>My first web page.</p>
</body>
</html>The minimum of a page: <!DOCTYPE html> activates standards mode, lang helps screen readers and translators, charset ensures correct umlauts and special characters, and the viewport tag ensures correct display on smartphones.
How to get started with HTML & CSS
You need three things: a text editor (recommended: Visual Studio Code, free – with the "Live Server" extension the browser reloads automatically on every change), a modern browser (Chrome, Firefox, Safari or Edge) and a folder for your project. A web page is initially just a text file with the extension .html.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Project</title>
<style>
body { font-family: system-ui, sans-serif; background: #fff; color: #222; }
h1 { color: #e34f26; }
</style>
</head>
<body>
<h1>It works!</h1>
<p>Save this file as <code>index.html</code> and open it in the browser with a double click.</p>
</body>
</html>You organize larger projects in several files: index.html, style.css (included with <link rel="stylesheet" href="style.css">) and optionally script.js. Make sure to save the file as UTF-8 and to set <meta charset="utf-8">, otherwise umlauts and other special characters appear broken.
The most important tools are the browser's developer tools (DevTools): right-click an element → "Inspect", or F12, or Cmd+Option+I (Mac) / Ctrl+Shift+I. In the "Elements" tab you see the DOM and the applied CSS rules, can change values live (colors, spacing, Flexbox properties) and can test the view for smartphones with the device icon.
HTML & CSS learning path
HTML Skeleton & Text
Document structure, headings, paragraphs, links, images and lists.
Semantic HTML & Page Structure
The right elements for header, navigation, content and footer – for people, search engines and screen readers.
Forms & Input Fields
Input types, labels, select fields and built-in validation.
Tables & Definition Lists
Mark up tabular data correctly and style it for readability.
CSS Basics: Rules, Colors & Type
Selectors and properties, units, colors and the cascade.
The Box Model
Content, padding, border, margin, box-sizing and display.
Selectors, Pseudo-classes & Specificity
Combinators, attribute and pseudo selectors and how conflicts are resolved.
Positioning & Stacking Order
relative, absolute, fixed, sticky and z-index.
Flexbox – One-Dimensional Layouts
Rows and columns with flexible items, alignment and spacing.
CSS Grid – Two-Dimensional Layouts
Columns, rows, areas and automatically responsive grids.
Responsive Design & Media Queries
Layouts that adapt to screen width and devices.
CSS Variables & Theming
Custom properties, var(), calc() and design tokens for themes and dark mode.
Transitions & Animations
State transitions, keyframes, performance and consideration for motion sensitivity.
Accessibility (a11y)
Keyboard, screen readers, contrast and ARIA – making web pages usable for everyone.
Modern CSS: :has(), Nesting, Layers & Container Queries
Current features that make a lot of JavaScript and preprocessor code unnecessary.
At a glance
More about HTML & CSS
Test & practice
Interactive quiz, timed exam with certificate, and exercises with an editor: