Example
Specify a background image for an HTML document:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
a{ color: #ffffff; font-weight:bold;}
</style>
</head>
<body background="/images/13-red-snapper-665.gif" style="color:#ffffff;">
<p><a href="http://Xhtml.co.il">Visit Xhtml.co.il!</a></p>
<p>The background attribute was deprecated in HTML 4, and is not supported in HTML 4.01 Strict DTD or in XHTML 1.0 Strict DTD. Use CSS instead.</p>
</body>
</html>Compatibility Notes
The background attribute of <body> is deprecated, and is not supported in HTML 4.01 Strict / XHTML 1.0 Strict DTD.
A deprecated element or attribute is one that has been outdated.
Deprecated elements may become obsolete in the future, but browsers should continue to support deprecated elements for backward compatibility.
Use CSS instead.
CSS syntax: <body style="background-image:url(/images/13-red-snapper-665.gif);>
CSS Example: Add a background image to a document
In our CSS tutorial you can find more details about the background-image property.
Definition and Usage
The background attribute specifies a background image for a document.
Browser Support
The
background attribute supported in all major browsersSyntax
<body background="value">
Attribute Values
| Value | Description |
|---|---|
| URL | The URL of the background image. Possible values:
|
Was this information helpful?

