HTML — The basics

Guide 01 / 4

HTML glossary

Give meaning to HTML terms by tying them to the recipe mini-blog.

Expected outcome :

Explain the concepts in your own words and recognise them in an example.

Reading
0%

01 · Getting your bearings before you start

Step 1/6 of the “À table !” running project, a recipe mini-blog. Go at your own pace: read, reproduce, modify, then check.

The path and the outcome of this step

Build a semantic recipe page that is readable without CSS and usable with a keyboard. The same dataset runs through all six courses: Soupe de carottes (20 min), Salade de tomates (10 min), Tarte aux pommes (45 min).

01. HTML : structurer trois recettes dans une page sémantique.
02. CSS : rendre le blog lisible sur mobile et sur ordinateur.
03. JavaScript : filtrer les recettes sans recharger la page.
04. PHP : produire les pages depuis des tableaux et traiter un formulaire.
05. MySQL : conserver les recettes dans une base relationnelle.
06. PDO : lire et ajouter des recettes depuis PHP avec des requêtes préparées.
Remember :

Each course has four guides: glossary, essentials, workshop and resources. The complete files are at the end of the workshop.

Prerequisites and environment

No language required. Know how to create a folder and save a file. Have a text editor, a browser and its developer tools ready. Save in UTF-8 as index.html, not index.html.txt. A double-click is enough for this HTML workshop; a local server will be used at the JavaScript step.

mini-blog/
  index.html       # HTML, CSS et JavaScript
  style.css        # ajouté à l’étape CSS
  app.js           # ajouté à l’étape JavaScript
  public/          # pages PHP accessibles par HTTP
  includes/        # fonctions, connexion et données PHP
  database/        # scripts SQL
Remember :

Create this working folder separately from the Technipédia course files. The example paths are relative to mini-blog/. Do not replace the HTML page of this platform.

The method: understand, reproduce, transform

Read a sheet, then type its example. Explain what changes on screen. Change one thing at a time and compare with the expected result. Keep a copy of the previous step before moving on.

1. Je lis et je reformule.
2. Je reproduis dans mon mini-blog.
3. Je change une valeur ou une règle.
4. Je vérifie et j’explique le résultat.
Remember :

Short snippets illustrate a concept; only the files announced as complete are to be copied as they are. Fragments are not to be concatenated into a single file.

02 · Understanding a web page

HTML gives the content its meaning. CSS will handle its presentation, JavaScript its interactions.

HTML and elements

HTML is a markup language. An element represents a part of the content: a heading, a paragraph or a recipe article. It is not a programming language.

<h1>À table !</h1>
Remember :

The opening tag, the content and the closing tag together form the element here.

Tags and nesting

Tags delimit elements. A child element sits inside its parent; the last element opened is always closed first.

<p>Une recette <strong>très simple</strong>.</p>
Remember : Avoid

simple

: the closing tags are crossed.

Attribute and value

An attribute specifies a property of the element. The name is followed by its value in quotation marks.

<html lang="fr">
<a href="#recettes">Recettes</a>
Remember :

lang announces the language; href indicates the link's destination.

Relative path and URL

A relative path starts from the current file; an absolute URL gives a complete address. Folder names and their case matter on many servers.

<img src="images/soupe.jpg" alt="Soupe de carottes servie dans un bol">
<a href="https://developer.mozilla.org/fr/">MDN</a>
Remember :

images/soupe.jpg assumes a file that is really present in mini-blog/images/; the complete workshop does not require a photo.

Semantics

Choose a tag for the meaning of the content: article for a self-contained recipe, nav for navigation, main for the main content.

<main>
  <article><h2>Soupe de carottes</h2></article>
</main>

DOM

The browser turns the HTML into a tree of objects called the DOM. The Elements tab shows this tree; JavaScript can then read and modify it.

document
└── html
    ├── head
    └── body
        └── main
            └── article

03 · Making the content accessible

A good structure helps people who use a keyboard, a screen reader or a small screen.

Page title and content headings

title names the tab and the page in search results. h1 to h6 organise the content into logical levels.

<title>À table ! · Recettes maison</title>
<h1>À table !</h1>
<h2>Nos recettes maison</h2>
<h3>Soupe de carottes</h3>
Remember :

Do not choose a heading level for its visual size: that is CSS's job.

Identifier and class

id identifies a single element in the page; class groups several elements for CSS or JavaScript.

<article id="soupe" class="recette">…</article>
<article id="salade" class="recette">…</article>

Alternative text

alt gives the useful information of an image when it cannot be perceived. A purely decorative image has alt="".

<img src="images/soupe.jpg" alt="Un bol de soupe orange garni de persil">
Remember :

Describe what adds meaning; avoid “image of”. Do not leave an informative photo without an alt attribute.

Form and label

A form brings fields together. label names a field for all users; for matches its id exactly.

<label for="titre">Titre de la recette</label>
<input id="titre" name="titre" required>
Remember :

A placeholder is a temporary hint, not a replacement for a label.

Link and button

A link leads to an address or a zone of the page. A button triggers an action such as submitting a form.

<a href="#soupe">Lire la soupe</a>
<button type="submit">Envoyer</button>
Remember :

Specify the type of buttons in forms. A button without a type generally submits the form.