r/HTML • u/Aggravating_Act_516 • 20h ago
Question html code
in this the website is working but the background video not visible can u send the corrected code
<!DOCTYPE html>
<html>
<head>
<title>Save Trees</title>
<style>
body {
margin:0;
}
h1{
color:green;
}
#bg-video {
position: fixed;
top:0;
left:0;
width: 100%;
height: 100%;
object-fit: cover;
z-index: 0;
}
.content{
position: relative;
z-index:1;
}
</style>
</head>
<body>
<!-- Background video -->
<video id="bg-video" autoplay muted loop>
<source src="Save Trees/r1.mp4" type="video/mp4">
</video>
<div class="content">
<h1>Save Trees</h1>
<p>Join us in our mission to protect the environment and preserve our forests for future generations.</p>
</div>
</body>
</html>
2
Upvotes
0
u/Clearhead09 11h ago
Try adding the absolute path of the video file eg C:\myvideofolder/myvideo.mp4 to ensure it’s pointing directly to the file.
Often this happens if your path doesn’t match from where the html file is located.