". The background attribute of the body tag is used to specify the background image of the HTML document. You can set multiple background images in one element and specify their positions."/> ". The background attribute of the body tag is used to specify the background image of the HTML document. You can set multiple background images in one element and specify their positions.">

Home >Web Front-end >HTML Tutorial >What is the code to set the background image in html

What is the code to set the background image in html

醉折花枝作酒筹
醉折花枝作酒筹Original
2021-04-07 17:50:4848414browse

htmlThe code for setting the background image is: "de3c12d2865b7edf3b1c11cdd67dbf9936cc49f0c466276486e50c850b7e4956"; 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.

What is the code to set the background image in html

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn