HomeCSSHow To Use Video As Text Background | Clip-Path Property

How To Use Video As Text Background | Clip-Path Property

Welcome to today’s tutorial. In today’s tutorial, we will learn how to use a video as a background for text. Even though this might sound complicated surprisingly this is quite easy to do.
For this tutorial, we will be using HTML, CSS and SVG. We will be generating SVG with some vector editing tools. So you don’t have to worry about that. Now let us begin with the tutorial.

Video Tutorial:

If you prefer to code along with the video tutorial, you can check out the video version of this tutorial down below. Also, you can check out other videos that I post on my youtube channel every alternate day.


Project Folder Structure:

Before starting to code we will check out the project folder structure. The project folder is called – Video In Text Background. Inside this folder, we have two files – index.html and style.css. They are HTML documents and stylesheets respectively.


We start with the HTML code. The HTML code consists of a div with a class name container. Inside the container, we have a video element. We set the src attribute of the video to whichever video we like.

We further add attributes like autoplay, muted and loop. Some browsers don’t allow autoplay if the video is not muted. Hence to ensure that the video plays automatically on window load we must add the muted attribute. Also, the loop attribute takes care that the video is played on loop.

Next, we use a vector editing software/tool to create the SVG text. I am using Adobe Illustrator. Though I am using a paid tool, you can find many free alternatives that do the exact same job.

In Illustrator we create an artboard that has the same dimensions as our video or else has the same aspect ratio. After we use a text tool to write the text of our choice and customize the font size. We right-click the text and click on the ‘Create Outlines’ Option.

In the next step, we export this as an SVG file. Now trace the SVG file in your folders and view the page source and copy the code. Paste it into the HTML section and wrap all the paths inside the clipPath tag with id text-path.

<!DOCTYPE html>
<html lang="en">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Video In Text Background</title>
    <!-- Stylesheet -->
    <link rel="Stylesheet" href="style.css"
      data-name="Layer 1"
      viewBox="0 0 600 339"
      <clipPath id="text-path">
        <path d="M306.28,66.85h59V81.73h-20.2v61.36H326.48V81.73h-20.2Z" />
        <path d="M374.59,66.85h18.57v76.24H374.59Z" />
        <path d="M561.16,66.85v61.9h24.32v14.34H542.59V66.85Z" />
    <div class="container">
      <video src="scenery.mp4" autoplay muted loop></video>


Now we code the CSS. We start by discarding any paddings and margins from the body. Following this, we set the height to 100vh and display it to the grid. The purpose of setting the display to the grid is so we can centre the video using the place-items property.

Next, we set the dimensions of SVG to zero as we don’t need the SVG element but just its ID.

Now for the container, we set the clip-path property to URL consisting of the id text-path. This property will clip the video into the shape of the text and you will get the desired effect.

Next, we set the width of the container to 600px. Lastly set the width of the video to 100%. That’s it for this tutorial.

body {
  padding: 0;
  margin: 0;
  height: 100vh;
  display: grid;
  place-items: center;
svg {
  height: 0;
  width: 0;
.container {
  clip-path: url(#text-path);
  position: absolute;
  width: 600px;
  transform: translateZ(0);
video {
  width: 100%;




Please enter your comment!
Please enter your name here

thirteen + six =

Most Popular