How to add a video background to a hero section in WordPress
Updated
In the WordPress block editor, add a Cover block, choose a video from your Media Library (or a URL), turn on full height, and type your heading inside it. The Cover block already outputs a muted, looping, inline-autoplay video, so no plugin is needed.
A seamless 3D hero loop: the kind of video this guide is about
Option 1: the Cover block
- 1Type
/coveron a new line (or use the + inserter) and add a Cover block at the top of the page. - 2Choose Upload or Media Library and pick your video. Recent versions also let you embed a video from a URL.
- 3In the block settings, turn on Toggle full height, set a poster image, and adjust the overlay colour and opacity for contrast.
- 4Type your heading and buttons inside the Cover block, then preview on desktop and phone.
Limits to know
- The Cover block outputs
<video autoplay muted loop playsinline>, which is what browsers need to autoplay. - Upload size limits come from your host or WordPress.com plan, not the block.
- Pausing for visitors with reduced motion was added to the block's code in late 2026. Check that your WordPress version includes it, or add the CSS from Option 2.
Option 2: a Custom HTML block
A Custom HTML block gives you full control (several formats, a transparent version, a player script). On self-hosted WordPress, scripts need the unfiltered_html capability, which Administrators and Editors have on a single site (only Super Admins on Multisite). WordPress.com strips script, style and similar tags unless you're on a paid plan with hosting features activated.
- 1Upload your video and poster to the Media Library and copy their file URLs.
- 2Add a Custom HTML block where the hero should be and paste the snippet below with your URLs.
- 3Click Preview inside the block, then check the live page.
<section class="hero">
<video class="hero__video" autoplay muted loop playsinline
preload="metadata" poster="/hero-poster.webp" aria-hidden="true">
<source src="/hero-loop.av1.webm" type='video/webm; codecs="av01.0.08M.10"'>
<source src="/hero-loop.mp4" type="video/mp4">
</video>
<div class="hero__content">
<h1>Your headline</h1>
</div>
</section>
<style>
.hero { position: relative; isolation: isolate; min-height: 90vh; overflow: hidden; }
.hero__video { position: absolute; inset: 0; z-index: -1;
width: 100%; height: 100%; object-fit: cover; }
@media (prefers-reduced-motion: reduce) {
.hero__video { display: none; }
.hero { background: url(/hero-poster.webp) center / cover; }
}
</style>Things that trip people up
- Some caching or optimisation plugins lazy-load or defer videos and scripts; exclude the hero if it stops autoplaying.
- Page builders (Elementor and others) have their own background-video settings; this guide covers the core block editor.
The one-line version
Edgeloop loops ship with a small player that does all of the above for you: the right format per browser, a poster while it loads, pausing off-screen, reduced-motion support and a transparent version for your own background.
<script src="https://edgeloop.studio/hero-loop.js" defer></script>
<hero-loop src="/loops/your-loop/" focus="right center"></hero-loop>Collection 01 opens soon. Join the waitlist for 3 free loops.
Questions
Do I need a plugin for a WordPress video background?
No. The core Cover block supports video backgrounds with autoplay, mute, loop and a poster image.
Why does WordPress remove my script tag?
Your user role needs the unfiltered_html capability on self-hosted WordPress. On WordPress.com, scripts are stripped unless you're on a paid plan with hosting features activated.