Skip to content

How to Add a YouTube Video Background in Divi (2026)

Divi will not accept a YouTube link as a background video, but a Code module makes it work. The exact method, the looping trap, and when to self-host.

Sunny Kumar
Sunny Kumar8 min read
TL;DR

Divi cannot use a YouTube URL as a background video. Its built-in video background only accepts self-hosted MP4 or WebM files. To get a YouTube backdrop you add a Code module with a YouTube iframe set to position absolute behind your content, then layer your text row on top with a higher z-index. For most sites a self-hosted, compressed MP4 loads faster and is the better choice.

The first time a client asked me for a YouTube video behind their hero in Divi, I opened the section settings, looked for the field, and there was none.

Divi will not take a YouTube link as a background. There is no setting for it.

Its built-in video background only accepts a file you upload, an MP4 or WebM. Paste a YouTube URL and nothing happens. Elegant Themes' own docs say the same: only self-hosted videos work as backgrounds.

So you build it by hand. I have set this up on a few sites now, and the trick that holds up is one Code module and a bit of CSS.

Here is how it works, the looping bug that catches everyone, and why I usually talk people out of YouTube and into a self-hosted file.

Can Divi use a YouTube video as a background?

Not through any setting. This is the part the recycled guides skip: there is no "paste your YouTube URL here" box in Divi's background tab.

The video background field is for self-hosted files only. To get a YouTube clip back there, you fake it. You drop the YouTube player into the section yourself with a Code module, push it behind everything, and float your real content on top.

It is not a Divi feature. It is a layout you assemble, and the whole thing rests on one idea: layers.

Diagram showing a Divi section with a YouTube iframe Code module positioned absolutely behind the content, and a content row layered on top with a higher z-index
The whole workaround is layering: the video sits behind on z-index 0, your content sits in front on z-index 2.

The three ways to do it, compared

There are three honest routes. Pick by how much control you want and how much you care about speed.

MethodWhat it isBest when
Code module + iframeHand-built YouTube embed, layered behind your contentYou want full control and no extra plugin
A background pluginA plugin that adds YouTube backgrounds as a settingYou want it point-and-click, no code
Self-hosted videoDivi's native background with your own MP4You care most about speed and Core Web Vitals

I reach for the Code module on most builds. But if speed is the priority, scroll to the self-hosted option first, because that is the one I actually recommend more often than not.

Method 1: the Code module workaround

This is the real answer to the search. It needs no plugin and works on any Divi section.

Step 1

Add a section and a Code module

In the Divi Builder, add a standard section with a single-column row. Inside that row, add a Code module. This is where the YouTube player will live.

Divi Builder Insert Module dialog with 'code' typed in the search box and the Code module highlighted
Inside the row, click to add a module, search 'code', and pick the Code module.

Leave the section's own background plain. You are not using the background tab at all here.

Step 2

Paste the YouTube iframe

Open your video on YouTube, click Share, then Embed, and copy the iframe.

YouTube Share dialog with the Embed option highlighted in the top-left corner
On the video, click Share, then the Embed (</>) option to get the iframe code.

Paste it into the Code module, then edit the src URL so it behaves like a backdrop instead of a player.

html
<iframe
  src="https://www.youtube.com/embed/VIDEO_ID?autoplay=1&mute=1&loop=1&playlist=VIDEO_ID&controls=0&showinfo=0&modestbranding=1"
  frameborder="0" allow="autoplay; encrypted-media" allowfullscreen>
</iframe>

Swap both copies of VIDEO_ID for your real video ID, the bit after watch?v= in the YouTube URL.

Divi Code Settings module with a YouTube iframe embed code pasted into the code box
The iframe pasted into the Code module's Content box, ready for the background parameters.

Step 3

Set the five background parameters

The parameters on the end of that URL are what turn a normal embed into a silent, looping background. Miss one and it breaks.

Annotated YouTube embed URL showing autoplay, mute, loop, playlist and controls parameters with an explanation of each
The five switches that make a YouTube embed read as a background. The playlist parameter is the one almost every guide forgets.

The one that catches people is loop=1. On a single video it does nothing on its own. YouTube only loops one video when you also add playlist=VIDEO_ID with the same ID. Forget it and your video plays once, then freezes on the last frame.

Step 4

Layer the video behind your content

Now the CSS that makes it a background. In the Code module Advanced tab, add custom CSS so the iframe fills the section and sits behind everything:

css
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
min-width: 100%; min-height: 100%;
width: 177.77vh; height: 56.25vw;
z-index: 0;
pointer-events: none;

On the section, set overflow: hidden so the oversized video is clipped to the section. On your content row, set position: relative and z-index: 2 so your text sits on top and stays clickable.

The width/height values keep the video at a 16:9 ratio while always covering the section, so you never get black bars.

Tip

Always add a fallback overlay

A bright video makes white text unreadable. Add a dark overlay between the video and your content, a row with a semi-transparent black background, or set a background colour on the content row at around 40% opacity. It also covers the split second before YouTube's player loads.

The honest catch with this method: you are loading the full YouTube player on page load. That is real weight, and it shows up in your speed scores. More on that below.

Method 2: a background plugin, if you would rather not code

If editing iframes and CSS is not your thing, a plugin adds YouTube backgrounds as a proper setting. The one I would use is Advanced WordPress Backgrounds by nK. It is free, on the official repository, and it actually handles YouTube, Vimeo and self-hosted video backgrounds with overlays and parallax built in.

The Advanced WordPress Backgrounds (AWB) plugin page on WordPress.org, by nK, with a Download button
Advanced WordPress Backgrounds (AWB) by nK on WordPress.org: free, maintained, and it handles YouTube backgrounds as a setting.
4.7/530,000+ installsFreeTested to WP 7.0on WordPress.org

It adds its own block and works alongside Divi, so you place its block in a Divi section and pick YouTube as the background type. The trade-off is the same as any plugin: one more thing to keep updated, and you are still pulling YouTube's scripts, so it is no lighter than the Code module on speed.

Get Advanced WordPress Backgrounds

Avoid the abandoned ones. A few old tutorials still point at jQuery-era plugins that have not been updated in years. On a current WordPress and PHP version those break, so stick to a plugin that shows a recent "tested up to" version.

Method 3: self-host the video, the one I usually recommend

Here is the position I land on most of the time: skip YouTube entirely and use Divi's real video background with your own file.

This is the only route that uses Divi's built-in feature the way it was meant to be used. Open the section, go to the Background tab, click the video icon, and upload an MP4 (add a WebM too for wider support). No code, no layering, no looping trap.

The win is speed. You load one small video file instead of the entire YouTube player and its tracking scripts. For a background loop, where nobody needs the controls or the "watch on YouTube" link anyway, that is pure upside.

The steps to do it well:

  • Keep the clip short, 8 to 12 seconds, looping. A background does not need a full video.
  • Compress hard. Aim for a file under a few megabytes. A 40 MB hero video will wreck your load time.
  • Don't serve the file off your own server. Host it on a proper video CDN so it is not eating your origin bandwidth.
  • Divi mutes and loops it for you, so there is no parameter to remember.

Where I host the video: Gumlet

The piece people skip is where the file lives. Drop a heavy MP4 in your media library and it is served off your own server, uncompressed, with no edge delivery. That is the part that actually hurts your scores.

I host these on Gumlet. It transcodes whatever you upload, compresses it properly, and delivers it from the edge closest to the visitor, so the video starts fast instead of dragging your origin down. You get a clean embed and a real CDN without building the pipeline yourself.

Gumlet video hosting homepage with the headline Video hosting that's fast, ad-free, and secure, and a Start for free button
Gumlet handles the transcoding, compression and edge delivery for you, which is exactly the part that makes a self-hosted background video fast.
Free planFrom $6/mo60 storage min · 100 GB bandwidth freeon Gumlet

There is a permanent free plan, so you can host a short background loop at no cost and only pay once you are delivering real volume. For a single hero video, the free tier is plenty.

Try Gumlet Free

The only reason to pick YouTube over a self-hosted file is if you genuinely cannot host it, or you want a third party to carry the bandwidth for a very heavy clip.

Will a video background slow my Divi site down?

Yes, if you are not careful, and this is where I spend most of my time on these builds. A video header is the heaviest thing on the page.

A YouTube embed pulls in the player and its scripts whether the visitor watches or not. A fat self-hosted MP4 can be tens of megabytes. Either way it competes with your real content for load time, and Core Web Vitals notice.

Site speed is an engineering problem, not a plugin you install. The fixes are boring and they work: compress the file, keep it short, lazy-load anything below the fold, and never let a video be the thing that blocks your largest contentful paint. If a video header is tanking your scores, that is a fixable problem, not a reason to give up on the effect.

What about mobile?

Be honest about phones. Mobile browsers are strict about autoplay and protective of data, and a video background hurts load time most exactly where connections are slowest.

My default: hide the video on mobile and show a static fallback image instead. Divi's visibility settings let you disable the Code module or the video section on phone, and you drop in a still frame as the background there. Visitors on a phone get a fast, sharp image; visitors on desktop get the motion. Nobody gets a janky, half-loaded player.

Want a fast Divi site, video header and all?

I build and tune Divi and WordPress sites so the design effects you want do not cost you your speed scores. If a video background or a heavy theme is dragging your site down, let's fix it properly.

See WordPress development

Final take

Divi cannot take a YouTube link as a background, full stop. You either layer it in by hand with a Code module, lean on a maintained plugin like Advanced WordPress Backgrounds, or self-host a compressed MP4 and use Divi's native feature.

The Code module method is the one people search for, and it works once you remember the playlist parameter for looping and the mute parameter, since browsers block autoplay with sound on. But nine times out of ten, a short, well-compressed self-hosted video is the better call. It gives you the same effect without dragging the whole YouTube player onto every page load.

Whichever route you pick, compress the file, hide it on mobile, and keep an eye on your speed. The effect is only worth it if the page still loads fast.

Common questions

Can Divi use a YouTube video as a background?

Not directly. Divi's built-in video background setting only accepts self-hosted MP4 or WebM files. To use a YouTube video you add a Code module with a YouTube iframe, position it absolutely behind your content, and layer your text on top with a higher z-index.

Why won't my YouTube background video loop in Divi?

Because loop=1 alone does nothing on a single YouTube video. You must also add playlist=VIDEO_ID with the same video ID to the embed URL. Without that second parameter the video plays once and freezes on the last frame.

Why won't my YouTube background autoplay?

Browsers block autoplay when sound is on. Add mute=1 to the iframe URL so the video starts muted, and autoplay will work. This is a browser rule, not a Divi setting, so it applies to every site and every theme.

Is a YouTube background or a self-hosted video better for Divi?

A self-hosted, compressed MP4 is usually better. It skips the heavy YouTube player scripts, so it loads faster and scores better on Core Web Vitals. Use YouTube only when you cannot host the file yourself or want YouTube to handle the bandwidth.

Will a video background slow down my Divi site?

Yes, if you are careless. A YouTube embed pulls in the full player and tracking scripts, and an uncompressed MP4 can be tens of megabytes. Compress the file, keep it under about 10 seconds, and never autoplay a video background on mobile.

Do YouTube video backgrounds work on mobile in Divi?

Often not reliably. Mobile browsers are strict about autoplay and data use, and a background video hurts load time most on phones. The safe pattern is to hide the video on mobile with Divi's visibility settings and show a static fallback image instead.

Written by
Sunny Kumar
Sunny KumarSEO Specialist & product builder

SEO Specialist and product builder with 10+ years in search. The notes come from the work, not the theory.

Work with TheGuideX

Reading about it is the easy part.

Send us the site and the problem. Your first reply comes from Sunny Kumar — not a sales team — and tells you if it is a fit.