0% completed
In this lesson, you'll learn how to set backgrounds using HTML-only techniques. Although the HTML background
attribute is considered deprecated in favor of CSS, it is still a simple way to understand how a background image can be applied to an entire page.
In older versions of HTML, the background
attribute was used on the <body>
element to set a background image for the entire page. This method does not require any CSS.
Syntax:
<body background="path/to/background.jpg"> <!-- Page content --> </body>
background
Attribute: Directly assigns an image file to be used as the page background.Example:
Explanation:
<body>
tag includes the background
attribute that links to the image URL.Deprecated Method:
The background
attribute is deprecated in HTML5. Modern web development uses CSS (with the background-image
property) for more control and flexibility.
No Advanced Control:
Using the HTML background
attribute does not allow for control over properties like repeat, size, or position. For full control over a background's appearance, learning CSS is recommended later.
For Learning Purposes:
While not best practice for production sites, using the HTML method helps beginners understand the concept of assigning a background image to a web page without getting into CSS.
By starting with HTML-only techniques, you can grasp the fundamentals of applying backgrounds. In CSS course, you'll explore more advanced methods using CSS, which allow for detailed control and better compatibility with modern web standards.
.....
.....
.....