HTML: Include background image - how it works
The background of an HTML page does not have to be monochrome. You can integrate your own background images and make your website graphically more individual.
Include the background image using the "style" attribute
You can also include a background image in HTML without using CSS.
- Give the body tag of your HTML page an attribute.
- Namely a "style" attribute.
- It looks like this: "".
- In this case the file "mein background.webp" should be in the same folder as your HTML file.
Obsolete: the "background" attribute
You can still use the "background" attribute. But it is not a good style, so to speak, it is "deprecated".
- Once the design was not isolated from the content.
- For example, the following code was used here: "".
The "style" attribute refers to the style sheet idea, the separation of layout and content. You can achieve even more elegant HTML programming if you really separate the design and layout from the content. You can do this using CSS. In another practical tip, we will explain the differences between HTML and CSS.