Open In App

How background attribute is deprecated in HTML5 ?

Last Updated : 17 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will know the Deprecation of background Attribute, along with understanding its implementation through the examples. Attributes in HTML are used to provide additional features to the elements. The attributes are specified in the tags.

The background attribute is used to specify or set all background style properties at once, like – size, color, image, origin, repeat, position method. In other words, it is used to define the background effects that can be used with the elements.  

Syntax:

<body background="url">Content</body>

HTML5 deprecates various elements like font, center, background, and many others & these effects can be implemented using CSS & which is used to separate the presentation style of a web page from its content. CSS provides style information for a web document & helps to simplify the task of maintaining a website by separating the formatting information from the structure and content of the website.

Please refer to the What are the HTML tags that deprecated in HTML5? article for more details about the deprecated tags & attributes.

Example: This example describes the use of the background attribute with <body> tag, for adding the image URL in the background. 

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title> HTML Background Attribute </title>
</head>
 
<body background=
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>HTML background Attribute</h2> <a href="#">
            It is a Computer Science portal For Geeks
        </a>
    </center>
</body>
 
</html>


Output:

HTML background attribute

Note: The background attribute is deprecated in HTML5. We can use the CSS background-image Property that facilitates setting the background images for an element.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads