Steps to load a background image in a webpage
To set a background image for a webpage, you can use CSS. You need to use the background-image
property in your CSS file or in a <style>
tag.
Steps:
- Choose or prepare an image for the background.
- Use CSS to link the background image to the
<body>
or any other HTML element.
Example code:
<!DOCTYPE html>
<html lang=”en”>
<head>
<meta charset=”UTF-8″>
<title>Background Image</title>
<style>
body {
background-image: url(‘background.jpg’);
background-size: cover; /* Ensures image covers entire screen */
background-position: center; /* Centers the image */
}
</style>
</head>
<body>
<h1>Welcome to My Page</h1>
</body>
</html>
In the example above, background.jpg
is the image file used as the background.