Full Screen Video Background With Text Overlay

Code Snippet:Full Screen Video with Text Overlay
Author: Lisa Catalano
Published: 3 weeks ago
Last Updated: October 30, 2025
Downloads: 124
License: MIT
Edit Code online: View on CodePen
Read More

Here’s a step-by-step guide on how to create a captivating Full Screen Video Background With Text Overlay for your website. This effect adds visual appeal and can enhance the user experience.

Step 1: Include Header Assets

Add the necessary CSS links and meta tags within the section of your HTML document. This includes links to Google Fonts and viewport settings.

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;900&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1">

Step 2: HTML Structure

Create the HTML structure for the video background and the text overlay. Use semantic HTML elements to organize your content.

<header class="video-header">
<!--   <video src="https://drive.google.com/uc?id=1QmPm1EdHE0yLepVKu8FqqpPxmNKSxwnC" autoplay loop playsinline muted></video> -->
  <video src="https://drive.google.com/uc?id=1QmPm1EdHE0yLepVKu8FqqpPxmNKSxwnC" autoplay loop playsinline muted></video>

  <div class="header-text">
    <h1>
      Exploring
      <span>The Sea</span>
    </h1>
  </div>
  <div class="description">
    <p>This is an example of a full screen video being shown as a background at any screen size. 
      This is accomplished with giving video absolute positioning, full viewport width and height, and using 'object-fit: cover;'
    </p>
    <p class="credit">Video credit: Taryn Elliot on <a href="https://www.pexels.com/video/colorful-fish-swimming-among-seaweed-5548030/">pexels.com.</a></p>
  </div>
</header>

Step 3: Styling with CSS

Apply CSS styles to position the video as a full-screen background, center the text overlay, and style the description.

html, body {
  font-family: 'Raleway', sans-serif;
  background-color: teal;
}
video {
  width: 100dvw;
  min-height: 100dvh;
  position: absolute;
  top: 0;
  left: 0;
  object-fit: cover; 
}
.header-text {
  position: absolute;
  color: white;
  display: flex; 
  flex-direction: column;
  justify-content: center;
  text-align: center;
  transform: translateY(-5rem);
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;  
}
.header-text h1 {
  font-weight: 400;
  font-size: 1.75rem;
  text-transform: uppercase;
  line-height: 1;
}
.header-text span {
  display: block;
  font-weight: 900;
  font-size: 6rem;
}
.description {
  position: absolute;
  bottom: 0; 
  left: 0;
  right: 0;
  margin: auto;
  color: white;
  background-color: hsl(181deg 50% 20% / 70%);
  padding: 2rem; 
}
.description p {
  max-width: 40rem;
  margin-inline: auto;
  line-height: 1.6;
}
.credit {
  font-size: .75rem;
}
.credit a {
  color: white; 
  text-underline-offset: 2px;
}

By following these steps, you’ll be able to create a stunning full screen video background with text overlay to enhance your web projects.

Related posts:

Loading... ...

Loading preview...

Device: Desktop
Dimensions: 1200x800
Lines: 0 Characters: 0 Ln 1, Ch 1

Leave a Comment

About W3Frontend

W3Frontend provides free, open-source web design code and scripts to help developers and designers build faster. Every snippet is reviewed before publishing for quality. Learn more.