<protocole>://<nomserveur>[:port]/<chemin>
IP ⇔ Nom de Domaine / Machine
<
nom
>
(ex : <p> </p> pour un paragraphe)
<balise>contenu</balise>
(ex: <br/> <br> pour un saut de ligne)
<balise/>
<balise>
(ex: <img src="hello.jpg" alt="Hello"> pour afficher une image)
"
pour définir la valeur d'un attribut<balise attribut="valeur">
Ctrl+U
<!-- Ceci est un commentaire -->
<, >, ",
' et &
qui pourraient être confondu avec le balisage HTML&entite;
&#numero;
< | < | < |
> | > | > |
& | & | & |
" | " | " |
' | ' | ' |
acute, grave,
circ, uml
à : à
é : é
ö : ö
î : î
Il existe d'autres entités :
€
etc.
.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Titre</title>
</head>
<body>
<!-- Commentaire : Hello world ! -->
Hello world !
</body>
</html>
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
</html>
<head></head>
<body></body>
La balise d'entête contient les informations caractéristiques de la page :
<meta charset="utf-8">
<title>Titre de la page</title>
Elle peut contenir d'autres informations
<meta name="description" content="Techniques Internet de base">
<meta name="keywords" content="HTML, CSS, JavaScript, PHP, SQL">
<meta name="author" content="Toto">
<section></section>
définit une section/partie de la page<article></article>
définit un article/post/commentaire ou un autre
contenu important de la page.<header></header>
définit l'entête de la page/section<footer></footer>
définit le bas de page de la page/section<aside></aside>
définit un texte qui se rapporte au sujet de la
page/section mais qui ne correspond pas directement au contenu
de la page<nav></nav>
définit les liens de de navigation<h1>Titre de niveau H1</h1>
<h2>Titre de niveau H2</h2>
<h3>Titre de niveau H3</h3>
<h4>Titre de niveau H4</h4>
<h5>Titre de niveau H5</h5>
<h6>Titre de niveau H6</h6>
<p>Paragraphe</p>
<p>
<em>Emphase par défaut en italique</em>
<strong>Accentuation par défaut en gras</strong>
<br>Saut de ligne
<hr>ligne horizontale pour séparer du texte
</p>
<cite></cite>
pour une citation<code></code>
pour du code<pre></pre>
pour du texte préformatté<samp></samp>
pour un exemple<blocknote></blocknote>
pour une note<address></address>
pour une adresse<sub></sub>
pour des indices<sup></sup>
pour des exposants<img>
permet d'afficher une image
Les attributs src
et alt
sont obligatoires
src
: URL de l'imagealt
: Texte alternatif qui remplace une image ne pouvant être
affichée ou qui est dicté par certains logiciels
d'accessibilité<img src="inc/img/html5.png" alt="logo html5" height="120" width="120">
<img src="inc/img/html.png" alt="logo html">
<figure>
<img src="inc/img/html5.png" alt="logo html5">
<figcaption>Titre de l'image</figcaption>
</figure>
.jpg
, .jpeg
) :
.gif
) :
.png
) :
.svg
) :
<svg>
href
permet de définir l'URL
l'attribut target
permet d'ouvrir le lien dans un autre onglet
<p>
<a href="#html-link" target="_blank">Un élément dans la même page</a><br>
<a href="./index.html?print-pdf" target="_blank">Une page du même site</a><br>
<a href="https://duckduckgo.com" target="_blank">Une page d'un autre site</a><br>
</p>
Les listes ordonnées/non-ordonnées
<ol><!-- ordererd list -->
<li>élément 1</li><!-- list item -->
<li>élément 2</li>
</ol>
<ul><!-- unordererd list -->
<li>élément 1</li>
<li>élément 2</li>
</ul>
Les listes de définitions
<dl><!-- definition list -->
<dt>terme 1</dt><!-- definition term -->
<dd>définition 1</dd><!-- definition description -->
<dt>terme 2</dt>
<dd>définition 2</dd>
</dl>
<ul>
<li>élément 1</li>
<li>élément 2
<ul>
<li>élément 2.1
<ul>
<li>élément 2.1.1</li>
</ul>
</li>
<li>élément 2.2</li>
</ul>
</li>
<li>élément 3
<ol>
<li>élément 3.1</li>
<li>élément 3.2</li>
</ol>
</li>
</ul>
<table></table>
début et fin de tableau<tr></tr>
Ligne du tableau<th></th>
Cellule du tableau (entête)<td></td>
Cellule du tableau (contenu)<caption></caption>
légende du tableau<thead></thead>, <tbody></tbody>, <tfoot></tfoot>
structure
du tableau<table>
<caption>Les chiffres</caption>
<tr>
<th>A</th><th>B</th><th>C</th><th>D</th>
</tr>
<tr>
<td>1</td><td>2</td><td>3</td><td>4</td>
</tr>
<tr>
<td>5</td><td>6</td><td>7</td><td>8</td>
</tr>
</table>
colspan
rowspan
<table>
<caption>Les chiffres</caption>
<tr>
<th>A</th><th>B</th><th>C</th><th>D</th>
</tr>
<tr>
<td rowspan="2">1</td><td colspan="3">2</td>
</tr>
<tr>
<td>3</td><td>4</td><td>5</td>
</tr>
</table>
<!--
<style>table, td, th { border: 1px solid black; }</style>
-->
<span></span>
: balise de type inline (pas de retour à la ligne)<div></div>
: balise de type block (retour à la ligne)id
: identifiant unique dans la page associé à une baliseclass
: classe qui peut-être associée à plusieurs éléments dans la pagetitle
: information affichée au survol de la souristexte
<div id="id" class="class">
texte
<span class="class" title="title">
texte
</span>
texte
</div>
texte
/* commentaire */
selecteur { propriete: valeur; }
selecteur1, selecteur2 {
propriete1: valeur1;
propriete2: valeur2;
}
le sélecteur universel | * |
tous les éléments de la page |
les balises | nom |
toutes les balises « nom » de la page |
les identifiants | #id |
l'élément d'identifiant « id » |
les classes | .class |
tous les éléments avec la classe « class » |
la combinaison simple | nom.class |
toutes les balises « nom » avec la classe « class » |
<style>
dans <head>
style
<head>
<style>p {color: red;}</style>
</head>
<body>
<p>paragraphe</p>
<p style="color: blue;">paragraphe</p>
</body>
.css
<link>
dans <head>
<head>
<link rel="stylesheet" type="text/css" href="inc/css/link.css">
<link rel="stylesheet" href="inc/css/link.css">
</head>
<body>
<p>paragraphe</p>
<p>paragraphe</p>
</body>
<head>
<style>
/* * { color: red; } */
p { background-color: green; }
#unique { text-align: center; }
.multiple { color: white; }
</style>
</head>
<body>
<h1>titre</h1>
<p class="multiple">paragraphe</p>
<p id="unique" class="multiple">paragraphe</p>
</body>
color
: couleur du textebackground-color
: couleur du fond#000
: noir : black#f00
: rouge : red#0f0
: vert : lime (pas green)#00f
: bleu : blue#fff
: blanc : white#000000
: noir#ff0000
: rouge#00ff00
: vert#0000ff
: bleu#ffffff
: blanc<head>
<style>
.vert-green { color: green; }
.vert-lime { color: #0f0; }
.vert-clair { color: #aaffaa; }
</style>
</head>
<body>
<p class="vert-green">vert</p>
<p class="vert-lime">vert</p>
<p class="vert-clair">vert</p>
</body>
opacity
rgb
, hsl
rgb(red, green, blue)
: 0-255 pour chaque couleurhsl(hue, saturation, lightness)
: hue de 0-360 (0, 360 :
rouge, 120 : vert, 240 : bleu), saturation et lightness
pourcentage de 0% à 100%rgba
et hsla
, le
dernier paramètre alpha est compris entre 0.0 et 1.0<head>
<style>
.vert-rgb { color: rgb(0, 255, 0); }
.vert-hsl { color: hsl(120, 100%, 50%); }
.vert-rgb-clair { color: rgba(0, 255, 0, 0.24); }
.vert-hsl-clair { color: hsla(120, 100%, 50%, 0.24); }
.vert-opacity { color: #0f0; opacity: 0.24; }
</style>
</head>
<body>
<p class="vert-rgb">rgb</p>
<p class="vert-hsl">hsl</p>
<p class="vert-rgb-clair">rgba</p>
<p class="vert-hsl-clair">hsla</p>
<p class="vert-opacity">opacity</p>
</body>
<head>
<style>
.background-detail {
background-color: lime;
background-image: url("inc/img/css3.png");
background-repeat: repeat; /* no-repeat, repeat-x, repeat-y */
background-attachment: scroll; /* fixed, local */
background-position: center center; /* left, right / top bottom */
}
.background-shorthand {
background: lime url("inc/img/css3.png") repeat scroll center center;
}
</style>
</head>
<body>
<p class="background-detail">les<br> propriétés<br> background<br> en<br> détails</p>
<p class="background-shorthand">Une<br> seule<br> propriété<br> background</p>
</body>
margin
<head>
<style>
.margin-detail {
margin-top: 6px; /* auto, % */
margin-right: 24px;
margin-bottom: 42px;
margin-left: 84px;
}
.margin-shorthand {
margin: 6px 24px 42px 84px;
/* 3 valeurs : margin: (top) (right/left) (bottom); */
/* 2 valeurs : margin: (top/bottom) (right/left); */
/* 1 valeur : margin: (top/right/bottom/left); */
}
</style>
</head>
<body>
<p class="margin-detail">les<br> propriétés<br> margin<br> en<br> détails</p>
<p class="margin-shorthand">Une<br> seule<br> propriété<br> margin<br> pour tout</p>
</body>
padding
<head>
<style>
.padding-detail {
padding-top: 6px; /* auto, % */
padding-right: 24px;
padding-bottom: 42px;
padding-left: 84px;
}
.padding-shorthand {
padding: 6px 24px 42px 84px;
/* 3 valeurs : padding: (top) (right/left) (bottom); */
/* 2 valeurs : padding: (top/bottom) (right/left); */
/* 1 valeur : padding: (top/right/bottom/left); */
}
</style>
</head>
<body>
<p class="padding-detail">les<br> propriétés<br> padding<br> en<br> détails</p>
<p class="padding-shorthand">Une<br> seule<br> propriété<br> padding<br> pour tout</p>
</body>
border-style
<head>
<style>
.border-style-detail {
border-top-style: solid;
border-right-style: dotted;
border-bottom-style: double;
border-left-style: dashed;
}
.border-style-shorthand {
border-style: solid dotted double dashed;
/* 3, 2 et 1 valeurs cf margin */
}
</style>
</head>
<body>
<p class="border-style-detail">les<br> propriétés<br> border-style en<br> détails</p>
<p class="border-style-shorthand">Une<br> seule<br> propriété<br> border-style</p>
</body>
border-width
<head>
<style>
.border-width-detail {
border-style: solid;
border-top-width: 1px;
border-right-width: 2px;
border-bottom-width: 3px;
border-left-width: 4px;
}
.border-width-shorthand {
border-style: solid;
border-width: 1px 2px 3px 4px;
/* 3, 2 et 1 valeurs cf margin */
}
</style>
</head>
<body>
<p class="border-width-detail">les<br> propriétés<br> border-width<br> en détails</p>
<p class="border-width-shorthand">Une<br> seule<br> propriété<br> border-width</p>
</body>
border-color
<head>
<style>
.border-color-detail {
border-style: solid; border-width: 3px;
border-top-color: black;
border-right-color: red;
border-bottom-color: blue;
border-left-color: green;
}
.border-color-shorthand {
border-style: solid; border-width: 3px;
border-color: black red blue green;
/* 3, 2 et 1 valeurs cf margin */
}
</style>
</head>
<body>
<p class="border-color-detail">les<br> propriétés<br> border-color<br> en< détails</p>
<p class="border-color-shorthand">Une<br> seule<br> propriété<br> border-color</p>
</body>
border
<head>
<style>
.border-detail {
border-width: 1px;
border-style: solid;
border-color: black;
}
.border-shorthand {
border: 1px solid black;
}
</style>
</head>
<body>
<p class="border-detail">les<br> propriétés<br> border<br> en<br> détails</p>
<p class="border-shorthand">Une<br> seule<br> propriété<br> border<br> pour tout</p>
</body>
<head>
<style>
.dimension {
width: auto; /* px, % */
height: auto; /* px, % */
min-width: auto; /* px, % */
max-width: none; /* px, % */
min-height: auto; /* px, % */
max-height: none; /* px, % */
overflow: visible; /* hidden, scroll, auto */
}
</style>
</head>
<body>
<p class="dimension">les<br> propriétés<br> des<br> dimensions</p>
</body>
display
display:
block;
<div>
, <h1> - <h6>
,
<p>
, <header>
, <footer>
, <section>
, etc.)display:
inline;
<span>
, <a>
,
<img>
, etc.)inline
ne peut pas être modifiédisplay:
inline-block; élément qui s'affiche comme un élément
inline
mais sur lequel ont peut modifier les dimensionsdisplay:
none; masque l'élément sur la pageposition
<head>
<style>
.position {
position: static; /* relative, fixed, absolute */
top: auto; /* px, % */
left: auto;
bottom: auto;
right: auto;
}
</style>
</head>
<body>
<p class="position">les<br> propriétés<br> des<br> positions</p>
</body>
float
<head>
<style>
.left {
float: left;
}
.right {
float: right;
/* clear: both; /* left, right */
}
</style>
</head>
<body>
<p class="left">float left</p>
<p class="right">float right</p>
</body>
<head>
<style>
.text {
text-align: center; /* left, right, justify */
text-decoration: underline; /* overline, line-through */
text-transform: uppercase; /* lowercase, capitalize */
text-indent: 24px;
letter-spacing: 5px;
word-spacing: 10px;
line-height: 140%;
}
</style>
</head>
<body>
<p class="text">les<br> propriétés du<br> texte</p>
</body>
<head>
<style>
.font-detail {
font-style: normal; /* italic, oblique */
font-variant: normal; /* small-caps */
font-weight: normal; /* bold, bolder, lighter */
font-size: medium; /* small, large, px, % */
font-family: "Times New Roman", Georgia, serif;
/* serif, sans-serif, cursive, fantasy, monospace */
}
.font-shorthand {
font: normal normal normal medium "Times New Roman", Georgia, serif;
/* font: medium "Times New Roman", Georgia, serif; */
}
</style>
</head>
<body>
<p class="font-detail">les<br> propriétés<br> d'une<br> police<br> en détails</p>
<p class="font-shorthand">Une<br> seule<br> propriété<br> font<br> pour tout</p>
</body>
<head>
<style>
table, td { border: 1px solid black; }
.table {
border-collapse: separate; /* collapse */
border-spacing: 2px; /* px */
/* 2 valeurs : horizontal, vertical spacing */
/* 1 valeur : horizontal/vertical spacing */
}
</style>
</head>
<body>
<table class="table">
<tr><td>cellule</td><td>cellule</td></tr>
<tr><td>cellule</td><td>cellule</td></tr>
</table>
</body>
<head>
<style>
.list-style-detail {
list-style-type: circle; /* square, upper-roman, lower-alpha */
list-style-position: inside; /* outside */
list-style-image: url('inc/img/css3.png');
}
.list-style-shorthand {
list-style: circle inside url('inc/img/css3.png');
}
</style>
</head>
<body>
<ul class="list-style-detail">
<li>élément 1</li><li>élément 2</li><li>élément 3</li>
</ul>
<ul class="list-style-shorthand">
<li>élément 1</li><li>élément 2</li><li>élément 3</li>
</ul>
</body>
vertical-align: top;
/* middle, bottom, etc. */
box-sizing: content-box;
/* border-box */
z-index: auto;
animation
transition
counter-reset
pointer
A B
div p
: toutes les balises <p>
qui sont contenues dans une balise <div>
A > B
div > p
: toutes les balises <p>
dont leur parent est une balise <div>
A ~ B
div ~ p
: toutes les balises <p>
qui suivent une balise <div>
A + B
div + p
: toutes les balises <p>
qui sont directement après une balise <div>
<a>
:link
: liens pas encore visités:visited
: liens visités:hover
: la souris survole l'élément (après :link
et :visited
):active
: la souris agit sur l'élément (après :hover
):first-child
: premier enfant d'une balise:last-child
: dernier enfant d'une balise:nth-child(n)
: n-ième enfant d'une balise
:nth-child(2)
: deuxième enfant d'une balise:nth-child(2n)
: enfants pairs d'une balise:nth-child(2n+1)
: enfants impairs d'une balise::first-line
: applique le style sur la première ligne du texte::first-letter
: applique le style sur la première lettre du
texte::before
: permet d'ajouter du contenu avant la balise avec la
propriété content
::after
: permet d'ajouter du contenu après la
balise avec la propriété content
[attribut]
: toutes les balises ayant cet attribut
[attribute=value]
: toutes les balises ayant cet attribut
dont la valeur est value
[attribute*="value"]
: toutes les balises ayant cet attribut
dont la valeur contient la valeur value
[attribute^="value"]
: toutes les balises ayant cet attribut
dont la valeur commence par la valeur value
[attribute$="value"]
: toutes les balises ayant cet attribut
dont la valeur finit par la valeur value
<form></form>
action
pour indiquer quelle page va traîter les donnéesmethod
pour dire comment transférer les données (get/post
)<input>
<form>
<label>default: <input name="default" placeholder="placeholder"></label><br>
<label>text: <input name="text" type="text" value="value"></label><br>
<label>password: <input name="password" type="password"></label><br>
<label>submit: <input name="submit" type="submit" value="submit"></label><br>
<label>button: <input name="button" type="button" value="button"></label><br>
<label>checkbox: <input name="checkbox[]" type="checkbox" value="checkbox1"></label><br>
<label>checkbox: <input name="checkbox[]" type="checkbox" value="checkbox2"></label><br>
<label>radio: <input name="radio" type="radio" value="radio1"></label><br>
<label>radio: <input name="radio" type="radio" value="radio2"></label><br>
</form>
<input>
name
permet d'identifier les donnéesvalue
associe une valeur à une donnée identifiéeplaceholder
texte affiché quand value
est viderequired
: ne peut valider le formulaire si la valeur est videdisabled
: désactive et ignore les données associéesreadonly
: empêche la modification de la valeurmaxlength
: longueur max autorisée pour value
pattern
: permet de définir le format accepté<input>
avancé<form>
<label for="idpassword">mot de passe: </label><br>
<label>password: <input type="password" id="idpassword" name="password"
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
title="Doit contenir un chiffre, une minuscule, une majuscule et au moins 8 caractères"></label><br>
<label>text: <input name="text" type="text" value="value" required="required"></label><br>
<label>disabled: <input name="disabled" type="text" value="value" disabled="disabled"></label><br>
<label>readonly: <input name="readonly" type="text" value="value" readonly="readonly"></label><br>
<label>maxlength: <input name="maxlength" type="text" value="value" maxlength="8"></label><br>
<button type="submit">valider</button>
</form>
<input>
version html5color
date
datetime
email
number
tel
url
<select></select>
<form>
<select name="select">
<optgroup label="Group 1">
<option value="value1">Valeur 1</option>
<option value="value2">Valeur 2</option>
</optgroup>
<optgroup label="Group 2">
<option value="value3">Valeur 3</option>
<option value="value4">Valeur 4</option>
</optgroup>
</select>
<select name="selectm" multiple="multiple">
<optgroup label="Group 1">
<option value="value1">Valeur 1</option>
<option value="value2">Valeur 2</option>
</optgroup>
<optgroup label="Group 2">
<option value="value3">Valeur 3</option>
<option value="value4">Valeur 4</option>
</optgroup>
</select>
</form>
<textarea></textarea>
et <button></button>
<form>
<textarea name="textarea" rows="2" cols="20">value</textarea>
<button type="button">button</button>
<button type="reset">reset</button>
<button type="submit">submit</button>
</form>
<fieldset></fieldset>
<form>
<fieldset>
<legend>Legend :</legend>
<label>Label : <input type="text"><br>
</fieldset>
</form>