To change the background color of the body element using CSS, you can use the background-color
property. Here’s an example code snippet that sets the body background color to light blue:
body {
background-color: lightblue;
}
In this code, body
refers to the HTML <body>
element, which represents the main content of a web page. The background-color
property specifies the background color of an element. The value lightblue
is a named color that represents a shade of blue.
You can also use hexadecimal color codes or RGB values to specify a custom background color. For example:
body {
background-color: #f0f8ff; /* Hexadecimal color code for light blue */
}
body {
background-color: rgb(173, 216, 230); /* RGB value for light blue */
}
These codes set the body background color to the same shade of light blue as the previous example, but using different color formats.
Remember to include this CSS code within the <style>
tags in the head of your HTML document or in an external stylesheet file.