Comment changer la couleur de fond d'un texte en HTML ?

Réponses rédigées par Antoine
Dernière mise à jour : 2022-08-11 12:44:28
Thèmes : html - texte - couleur - fond - css
Question

Bonjour, je voudrais faire un effet de Stabilo sur un texte HTML, et donc changer la couleur de fond du texte. Merci.

Réponse

Pour changer la couleur de fond d'un texte en HTML, vous pouvez entourer le texte par une balise <span>...</span>, puis créer une CLASS nommée stabilo avec la propriété CCS background-color :

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Comment changer la couleur de fond d'un texte en HTML ?</title>
<style> 
.stabilo { 
background-color: #FFFF00
} 
</style> 
</head>
<body>
Exemple de page Web avec <span class="stabilo">un texte stabiloté</span>.
</body>
</html>

Démonstration dans le Bac à codes.