Difference between revisions of "CSS: Backgrounds"

Line 1: Line 1:
 
==Background==
 
==Background==
You can use the <syntaxhighlight>background</syntaxhighlight> CSS property to modify the background of an element. The background consists of several parts.
+
You can use the <syntaxhighlight inline>background</syntaxhighlight> CSS property to modify the background of an element. The background consists of several parts.
  
 
==Background Color==
 
==Background Color==
The <syntaxhighlight>background-color</syntaxhighlight> property modifies the color of the background. For example, the code
+
The <syntaxhighlight inline>background-color</syntaxhighlight> property modifies the color of the background. For example, the code
  
 
<syntaxhighlight lang="css">
 
<syntaxhighlight lang="css">
Line 16: Line 16:
  
 
==Background Image==
 
==Background Image==
You can use the <syntaxhighlight>background-image</syntaxhighlight> property to use an image instead of a color/gradient:
+
You can use the <syntaxhighlight inline>background-image</syntaxhighlight> property to use an image instead of a color/gradient:
  
 
<syntaxhighlight lang="css">
 
<syntaxhighlight lang="css">

Revision as of 12:08, 23 December 2022

Background

You can use the background CSS property to modify the background of an element. The background consists of several parts.

Background Color

The background-color property modifies the color of the background. For example, the code

div{
    background-color: red;
}

will create the following:

Background Image

You can use the background-image property to use an image instead of a color/gradient:

div{
    background-image: url('/image.png');
}