What is the code to set the background image in html

醉折花枝作酒筹
Release: 2023-01-04 09:34:54
Original
48380 people have browsed it

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.

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>
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template