---
title: Body Background Attribute
localeTitle: 身体背景属性
---
## 身体背景属性

如果要添加背景图像而不是颜色，则一种解决方案是`<body background>`属性。它指定HTML文档的背景图像。

句法：

`<body background="URL">`

属性：

`background - URL for background image`

例：

```html

<html> 
  <body background="https://assets.digitalocean.com/blog/static/hacktoberfest-is-back/hero.png"> 
  </body> 
 </html> 
```

## body-background属性已折旧

在HTML5中不推荐使用body-background属性。设置`<body>`标签样式的正确方法是使用CSS。

有几个CSS属性用于设置元素的背景。这些都可以使用设置整个页面的背景。

## 看看这个：

*   [CSS背景属性](https://github.com/freeCodeCamp/guides/blob/master/src/pages/css/background/index.md)