htmlThe code for setting the background image is: "
"; set the background image of the web page through the background attribute. This attribute can be in an element Set multiple background images and specify their positions.
The operating environment of this tutorial: Windows 7 system, HTML4 version, Dell G3 computer.
Adding a background image to a web page can enhance the display effect of the web page and achieve better visual effects. When choosing a background image, you must not only look good, but also ensure that it does not overwhelm the content and affect the reading of the web page content. Usually use a dark background image with light text, or a light background image with dark text. The background
attribute is used to set the background image of the web page.
Basic syntax:
<body background="图片地址"></body>
The background attribute value is the path of the image. The path can be a relative address or an absolute address.
Example code:
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body background="../images/bg.jpg"> </body> </html>
The background image must be coordinated with the color of the illustrations and text. In order to ensure the speed at which the browser loads web pages, try not to use images that are too large in bytes.
Recommended study: "HTML Video Tutorial"
The above is the detailed content of What is the code to set the background image in html. For more information, please follow other related articles on the PHP Chinese website!