Adding a video background in Bubble requires an HTML element with a video tag positioned behind your page content using CSS. You embed a hosted MP4 video with autoplay, loop, and muted attributes, then use absolute positioning and z-index layering to place it behind all other elements. This tutorial covers hosting, embedding, overlay setup, and mobile fallback images for reliable performance.
Overview: Video Backgrounds in Bubble
This tutorial shows you how to add a full-page video background to your Bubble app. Since Bubble does not have a native video background element, you will use an HTML element with custom CSS to position a video behind your page content. The guide covers hosting your video, embedding it with autoplay and loop, handling z-index layering, and providing fallback images for mobile devices where autoplay may not work.
Prerequisites
- A Bubble app with at least one page to add the background to
- A video file hosted on a public URL (MP4 format recommended)
- Basic understanding of HTML video tags and CSS positioning
Step-by-step guide
Add an HTML element to your page for the video
Add an HTML element to your page for the video
In the Bubble editor, navigate to the Design tab for your target page. Click the '+' icon in the element palette and search for 'HTML'. Drag the HTML element onto your page. In the property editor, resize it to cover the full page — set width to 100% and height to 100%. Position it at coordinates 0,0 (top-left corner). Make sure this HTML element is at the bottom of your Element Tree so it renders behind all other elements. You can right-click it in the Element Tree and select 'Send to back'.
Pro tip: Name the HTML element something clear like 'html_video_bg' so you can find it easily in the Element Tree.
Expected result: An HTML element is placed on the page covering the full viewport, positioned behind all other elements.
Add the video embed code with autoplay and loop
Add the video embed code with autoplay and loop
Double-click the HTML element to open its editor. Paste the video code below, replacing the video URL with your hosted MP4 file. The video tag includes autoplay, loop, muted, and playsinline attributes — all four are required for autoplay in modern browsers. The CSS makes the video cover the full viewport, centers it, and hides overflow.
1<style>2 .video-bg-container {3 position: fixed;4 top: 0;5 left: 0;6 width: 100vw;7 height: 100vh;8 overflow: hidden;9 z-index: -1;10 }11 .video-bg-container video {12 min-width: 100%;13 min-height: 100%;14 width: auto;15 height: auto;16 position: absolute;17 top: 50%;18 left: 50%;19 transform: translate(-50%, -50%);20 object-fit: cover;21 }22</style>23<div class="video-bg-container">24 <video autoplay loop muted playsinline>25 <source src="https://your-hosting.com/your-video.mp4" type="video/mp4">26 </video>27</div>Expected result: The video plays automatically in the background, looping continuously with no audio, behind all page content.
Add a semi-transparent overlay for text readability
Add a semi-transparent overlay for text readability
If your page has text over the video, add a dark overlay to improve readability. Add a new Group element on top of the video in the Element Tree. Set its background color to black (#000000) with opacity at 40-60%. Size it to cover the full page and position it above the video HTML element but below your content elements in the Element Tree. Adjust the opacity based on your video — darker videos need 20-30% while bright videos may need 50-60%.
Pro tip: Adjust the overlay opacity based on your video brightness. Darker videos need less overlay, while bright or colorful videos need more.
Expected result: A semi-transparent overlay sits between the video and your text content, making text readable against the moving background.
Add a mobile fallback image
Add a mobile fallback image
Mobile browsers often restrict autoplay or consume too much data. Add a fallback by using a conditional on the HTML element. In the Conditional tab, add a condition: 'When Current page width is less than 768'. Set the property 'This element is visible' to 'no'. Then add a separate Image element with your fallback poster image, and set its conditional to the opposite — visible only when page width is less than 768. This way mobile users see a static image while desktop users get the video.
Expected result: Desktop users see the video background while mobile users see a static fallback image for better performance.
Optimize video file size for fast loading
Optimize video file size for fast loading
Large video files cause slow page loads. Keep your background video under 5MB if possible. Use HandBrake or an online video compressor to reduce file size. Set resolution to 1280x720 (720p) — full 1080p is unnecessary for a background. Keep duration to 15-30 seconds since it loops. Remove the audio track entirely. Host the video on a CDN like Cloudflare R2, AWS S3, or Cloudinary for fast global delivery.
Pro tip: WebM format offers better compression than MP4. Add a second source tag with WebM as the first option and MP4 as fallback for Safari.
Expected result: The video loads quickly without noticeably delaying page render time, even on slower connections.
Complete working example
1VIDEO BACKGROUND SETUP SUMMARY2=====================================34ELEMENT STRUCTURE (Element Tree order):5 1. HTML Element — video-bg (bottom/back)6 - Position: 0,07 - Width: 100%, Height: 100%8 - Contains: <video> tag with CSS9 2. Group — overlay (middle)10 - Background: #000000, opacity 40-50%11 - Width: 100%, Height: 100%12 3. Group — page-content (top/front)13 - Your actual page content here1415HTML ELEMENT CODE:16 <style>17 .video-bg-container {18 position: fixed;19 top: 0; left: 0;20 width: 100vw; height: 100vh;21 overflow: hidden; z-index: -1;22 }23 .video-bg-container video {24 min-width: 100%; min-height: 100%;25 position: absolute;26 top: 50%; left: 50%;27 transform: translate(-50%, -50%);28 object-fit: cover;29 }30 </style>31 <div class="video-bg-container">32 <video autoplay loop muted playsinline>33 <source src="YOUR_VIDEO.mp4" type="video/mp4">34 </video>35 </div>3637MOBILE FALLBACK:38 Conditional on HTML Element:39 When: Current page width < 76840 Property: This element is visible = no41 Image Element (fallback):42 When: Current page width < 76843 Property: This element is visible = yes4445VIDEO SPECS:46 Resolution: 720p (1280x720)47 Duration: 15-30 seconds48 File size: under 5MB49 Format: MP4 (add WebM first source)50 Audio: removed51 Hosting: CDN recommendedCommon mistakes when adding a Video Background to a Page in Bubble
Why it's a problem: Forgetting the 'muted' attribute on the video tag
How to avoid: Always include all four attributes: autoplay, loop, muted, and playsinline on the video tag
Why it's a problem: Using a video file that is too large (over 10MB)
How to avoid: Compress to 720p resolution, 15-30 seconds, and under 5MB using HandBrake or similar
Why it's a problem: Not providing a mobile fallback
How to avoid: Use a Bubble conditional to show a static image on screens narrower than 768px
Best practices
- Keep background videos short (15-30 seconds) since they loop continuously
- Always remove the audio track from background videos to save bandwidth
- Use 720p resolution — higher resolutions waste bandwidth on a partially obscured background
- Host your video on a CDN for fast global delivery rather than Bubble's file manager
- Add a poster attribute to the video tag so users see an image while the video loads
- Test on Safari, Chrome, and Firefox since video autoplay behavior varies
- Add a semi-transparent overlay between the video and text content for readability
Still stuck?
Copy one of these prompts to get a personalized, step-by-step explanation.
I want to add a looping video background to my Bubble.io landing page. The video is hosted on Cloudinary. How do I embed it so it autoplays, loops, stays behind content, and has a fallback image on mobile?
Add a full-page video background to my index page. The video URL is https://example.com/bg-video.mp4. Make it autoplay, loop, and stay behind all page content. Add a dark overlay for readability and a fallback image for mobile.
Frequently asked questions
Can I use a YouTube video as a background in Bubble?
Yes, but it requires embedding a YouTube iframe with parameters (autoplay=1, mute=1, loop=1, controls=0) and CSS to fill the viewport. YouTube's terms require visible branding, so a self-hosted MP4 is cleaner.
Why is my video background not autoplaying?
The most common cause is a missing 'muted' attribute. Modern browsers require videos to be muted for autoplay. Ensure your video tag has autoplay, loop, muted, and playsinline.
Does a video background affect my Bubble app's performance?
Yes. Video backgrounds add page weight and CPU usage. Keep the video under 5MB, use 720p, and provide a static image fallback for mobile to minimize impact.
Can I change the video dynamically based on the page or user?
Yes. Use Bubble's 'Insert dynamic data' inside the HTML element to insert different video URLs based on URL parameters, current user data, or custom states.
Will the video background work on all mobile devices?
Not reliably. iOS Safari and some Android browsers restrict video autoplay. This is why a mobile fallback image is essential for a consistent experience.
Can RapidDev help create a professional video landing page in Bubble?
Yes. RapidDev can design and implement a high-converting landing page with optimized video backgrounds, mobile responsiveness, and performance tuning.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation