Maison  >  Article  >  interface Web  >  Comment afficher la couleur de fond d'un élément en HTML ?

Comment afficher la couleur de fond d'un élément en HTML ?

WBOY
WBOYavant
2023-08-27 19:57:19707parcourir

Comment afficher la couleur de fond dun élément en HTML ?

Utilisez l'attribut bgcolor en HTML pour afficher la couleur d'arrière-plan d'un élément. Il est utilisé pour contrôler l’arrière-plan des éléments HTML, en particulier l’arrière-plan du texte des pages et des tableaux.

REMARQUE - HTML5 ne prend pas en charge cet attribut.

Exemple

Vous pouvez essayer d'exécuter le code suivant pour comprendre comment implémenter l'attribut bgcolor en HTML -

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Background Colors</title>
   </head>
   <body>
      <!-- Format 1 - Use color name -->
      <table bgcolor = "yellow" width = "100%">
         <tr>
            <td>
               This background is yellow
            </td>
         </tr>
      </table>

      <!-- Format 2 - Use hex value -->
      <table bgcolor = "#6666FF" width = "100%">
         <tr>
            <td>
               This background is sky blue
            </td>
         </tr>
      </table>

      <!-- Format 3 - Use color value in RGB terms -->
      <table bgcolor = "rgb(255,0,255)" width = "100%">
         <tr>
            <td>
               This background is green
            </td>
         </tr>
      </table>
   </body>
</html>

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Cet article est reproduit dans:. en cas de violation, veuillez contacter admin@php.cn Supprimer