HTML/CSS/CSS Attributes and Javascript Style Properties/background color

Материал из Web эксперт
Перейти к: навигация, поиск

"background-color" Example

   <source lang="html4strict">
   

<html> <head> </head> <body>

           








           background-color is red.

</body> </html>


     </source>
   
  


background-color: #ffffff

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

   <head>
       <title>background-color</title>
       <style rel="stylesheet" type="text/css">

body {

   background-color: yellow;

} div#one {

   width: 50px;
   height: 50px;
   border: 1px solid rgb(128, 128, 128);
   margin: 5px;
   float: left;
   background-color: #ffffff;

}

       </style>
   </head>
   <body>
   </body>

</html>

</source>
   
  


background-color: lightgray;

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html>

   <head>
       <title> Albert Einstein </title>
       <style type="text/css" media="all">
           p::first-letter {
               font-size: 200%;
               background-color: lightgray;
               border: 1px solid black;
           }
           p::first-line {
               letter-spacing: 5px;
           }
       </style>
   </head>
   <body>

This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test. This is a test.

   </body>

</html>

</source>
   
  


background-color: pink

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

   <head>
       <title>background-color</title>
       <style rel="stylesheet" type="text/css">

body {

   background-color: yellow;

} div#one {

   width: 50px;
   height: 50px;
   border: 1px solid rgb(128, 128, 128);
   margin: 5px;
   float: left;
   background-color: pink;

}

       </style>
   </head>
   <body>
   </body>

</html>

</source>
   
  


background-color: rgb(

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

   <head>
       <title>background-color</title>
       <style rel="stylesheet" type="text/css">

body {

   background-color: yellow;

} div#one {

   width: 50px;
   height: 50px;
   border: 1px solid rgb(128, 128, 128);
   margin: 5px;
   float: left;
   background-color: rgb(200, 0, 0);

}

       </style>
   </head>
   <body>
   </body>

</html>

</source>
   
  


background-color: transparent

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

   <head>
       <title>background-color</title>
       <style rel="stylesheet" type="text/css">

body {

   background-color: yellow;

} div#one {

   width: 50px;
   height: 50px;
   border: 1px solid rgb(128, 128, 128);
   margin: 5px;
   float: left;
   background-color: transparent;

}

       </style>
   </head>
   <body>
   </body>

</html>

</source>
   
  


If both digits are the same you could write just one, for example, #000000 for #000

   <source lang="html4strict">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

                     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

   <head>
       <title>background-color</title>
       <style rel="stylesheet" type="text/css">

body {

   background-color: yellow;

} div#one {

   width: 50px;
   height: 50px;
   border: 1px solid rgb(128, 128, 128);
   margin: 5px;
   float: left;
   background-color: #000;

}

       </style>
   </head>
   <body>
   </body>

</html>

</source>