Course Beginner Free
CSS — The basics
Style the recipe mini-blog and make it responsive: selectors, box model, flexbox, grid and mobile-first.
- 4 guides
- 39 concepts
Guides
- 01 Guide CSS glossary Explain the concepts in your own words and recognise them in an example.
- 02 Guide CSS essentials Choose and use the essential elements to complete this step of the blog.
- 03 Guide CSS workshop · À table ! Reproduce a working result, test it, then succeed at an exercise without copying.
- 04 Guide Resources and review Find reliable information and explain what you have built.
Suggested path
- 01. HTML: structure three recipes in a semantic page.
- 02. CSS: make the blog readable on mobile and on desktop.
- 03. JavaScript: filter the recipes without reloading the page.
- 04. PHP: produce the pages from arrays and process a form.
- 05. MySQL: keep the recipes in a relational database.
- 06. PDO: read and add recipes from PHP with prepared queries.
Sources and references
Beginner workshop, step 2/6. The complete files are materials to reproduce in a separate local project. Read the prerequisites, the expected results and the limits stated in the workshop.
Example files
Ajout dans head de index.html
<link rel="stylesheet" href="style.css">
style.css
/* Le sélecteur universel inclut aussi les pseudo-éléments. */
*, *::before, *::after { box-sizing: border-box; }
:root {
--fond: #fff8ed;
--texte: #29251f;
--accent: #8b351b;
--carte: #ffffff;
}
body {
margin: 0;
font-family: system-ui, sans-serif;
line-height: 1.6;
color: var(--texte);
background: var(--fond);
}
.entete, .pied { padding: 1.5rem 1rem; text-align: center; }
.entete { background: var(--accent); color: white; }
.entete a { color: inherit; }
nav { display: flex; justify-content: center; flex-wrap: wrap; gap: 1rem; }
a { color: var(--accent); text-underline-offset: 0.2em; }
.conteneur { width: min(100% - 2rem, 70rem); margin-inline: auto; }
section { margin-block: 2rem; }
h1, h2, h3, h4 { line-height: 1.25; }
.recettes { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
.recette {
padding: 1.25rem;
border: 1px solid #cbbba9;
border-radius: 0.75rem;
background: var(--carte);
overflow-wrap: anywhere;
}
.recette h3 { margin-top: 0; color: var(--accent); }
.meta { font-weight: 600; }
img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
label { font-weight: 600; }
input, select, button, textarea { font: inherit; max-width: 100%; }
input, select, textarea { padding: 0.5rem; border: 1px solid #796e61; border-radius: 0.25rem; }
button { padding: 0.5rem 1rem; border: 0; border-radius: 0.25rem; background: var(--accent); color: white; cursor: pointer; }
#filtres { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
/* Une règle display ne doit pas réafficher un contrôle marqué hidden. */
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #185ea0; outline-offset: 4px; }
.evitement { position: absolute; top: 0; left: 1rem; padding: 0.5rem; background: white; transform: translateY(-120%); }
.evitement:focus { transform: translateY(0); }
.pied { border-top: 1px solid #cbbba9; }
@media (min-width: 48rem) {
.recettes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
In the same series Step 2 of 6
- 1 Course HTML — The basics
-
2 Course CSS — The basics You are here
- 3 Course JavaScript — The basics
- 4 Course PHP — The basics
- 5 Course MySQL — The basics
- 6 Course PDO — The basics
In the same category
Development and production · Beginner
HTML — The basics
Build a semantic, accessible web page step by step with a running project: a recipe mini-blog.
Development and production · Intermediate
Node.js — The fundamentals
Understand the Node.js runtime: modules, asynchronous code, npm and building a small server.
Development and production · Beginner
JavaScript — The basics
Make the page interactive: variables, functions, the DOM and events to filter recipes without reloading.