Files
freeCodeCamp/guide/english/html/attributes/body-background-attribute/index.md

35 lines
987 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Body Background Attribute
---
2019-01-20 00:54:02 +01:00
## Body Background Attribute
2018-10-12 15:37:13 -04:00
If you want to add a background image instead of a color, one solution is the `<body background>` attribute. It specifies a background image for an HTML document.
Syntax:
`<body background="URL">`
Attribute:
`background - URL for background image`
Example:
```html
<html>
<body background="https://assets.digitalocean.com/blog/static/hacktoberfest-is-back/hero.png">
</body>
</html>
```
## body-background attribute is depreciated
2018-11-19 17:42:58 +09:00
The body-background attribute has been deprecated in HTML5. The correct way to style the ```<body>``` tag is with CSS.
2018-10-12 15:37:13 -04:00
There are several CSS properties used for setting the background of an element. These can be used on the <body> tag to set the background of an entire page.
2018-10-12 15:37:13 -04:00
## Check it Out:
2019-01-20 00:54:02 +01:00
* [CSS background](https://github.com/freeCodeCamp/guides/blob/master/src/pages/css/background/index.md)
2019-01-20 04:06:09 +05:30
* [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/background)
2018-10-12 15:37:13 -04:00