Home >Web Front-end >HTML Tutorial >How to set the background of the entire web page in html
Set the background of the entire web page in HTML by following these steps: Create a <body> element and add the background attribute. Use the url() function to specify an image path or set the background color using a hexadecimal color code or color name. Optionally, set other options such as background-repeat and background-position. Close the <body> element.
How to set the background of the entire web page in HTML
It is very simple to set the background of the entire web page in HTML. You can use the background
attribute.
Steps:
Create <body>
Element:
<code class="html"><body></code>
Add background
Attribute:
The background can be set using the following values:
Image : Use the url()
function to specify the image path, for example:
<code class="html"><body background="bg.jpg"></code>
Color: Use hexadecimal color code or Color name, for example:
<code class="html"><body background="#0000FF"></code>
Other options:
background
The property also allows you to set additional options , for example:
background-repeat
: Control whether the background is repeated, for example:
<code class="html"><body background="bg.jpg" background-repeat="no-repeat"></code>
background-position
: Control the position of the background on the page, for example:
<code class="html"><body background="bg.jpg" background-position="center"></code>
Close <body>
Element:
<code class="html"></body></code>
Example:
The following example demonstrates how to set the Blue background:
<code class="html"><body background="#0000FF"> <!-- 网页内容 --> </body></code>
Tips:
The above is the detailed content of How to set the background of the entire web page in html. For more information, please follow other related articles on the PHP Chinese website!