To embed video on a website, upload the video to a host or make the file available online, then add the host’s embed code or an HTML <video> element to your page. The best method depends on your site: YouTube is easy and familiar, while a managed video host or a well-configured HTML5 player gives you more control over the viewing experience.
📋 TL;DR
- For a quick public embed: Paste a YouTube or Vimeo URL into a supported video block, or use the provider’s iframe code.
- For direct control: Use the HTML5
<video>element and arrange your own storage, encoding, and delivery.- For a business page: Consider a managed host if you want a branded player and someone else to handle video delivery.
- For every method: Check the published page on mobile, provide captions, and measure performance instead of assuming one player is fastest.
Compare the five ways to embed video
YouTube, Vimeo, other iframe embeds, and managed hosts overlap: a managed host may also provide an iframe. The distinction is useful because an iframe describes how the player is inserted, while a managed host describes who handles the video and its delivery.
| Method | Best fit | Cost | Branding and delivery | Performance and SEO considerations |
|---|---|---|---|---|
| YouTube iframe | Public videos and simple setup | Free to embed; account and content rules apply | YouTube player and platform features; ads or related videos may appear | Third-party player requests can affect page speed; add useful page context and check indexing |
| Vimeo iframe | Portfolios and presentation-focused videos | Plans and limits vary | Player customization depends on the plan; Vimeo handles delivery | Player overhead varies; check privacy, usage limits, and page markup |
HTML5 <video> |
Sites with control over their media infrastructure | Hosting and bandwidth costs depend on usage | Native browser controls or a custom player; you manage the files and delivery | Can be lightweight, but large files and poor delivery can hurt playback; add video metadata yourself |
| Generic provider iframe | A host without a dedicated integration for your site | Depends on the provider | Features and branding depend on the host and plan | Test the actual embed; check captions, loading behavior, and structured data |
| Managed host with site integration | Business pages that need a controlled player and managed delivery | Usually paid; compare plan limits | Provider handles hosting and delivery; customization varies | Performance and schema support depend on the provider and configuration |
All five can work on WordPress, Shopify, Squarespace, Webflow, and a hand-coded site when the platform and your plan allow the necessary embed code. The practical difference is where you add it: a video block, a custom HTML area, a theme template, or the page source.
ℹ️ What is an embed code? An embed code is a snippet you add to a page to display content. For video, it might be an
<iframe>that loads a provider’s player, an HTML<video>element that points to a media file, or a provider’s script and player tag.
Which video embed method should you choose?
Start with the job of the page and the resources you have to maintain the video.
- Choose YouTube when you want a free, familiar embed and your video also belongs on a public discovery platform.
- Choose Vimeo when its player presentation and plan features fit your site and expected usage.
- Choose HTML5 video when you want direct control and can manage encoding, storage, bandwidth, and delivery.
- Choose another provider’s iframe when you already use that host and it supplies the features your page needs.
- Choose a managed host with an integration when you want the provider to handle delivery and offer a player suited to your site.
For example, a tutorial in a blog post may be well served by a YouTube embed. A product demo beside a purchase button may benefit from a player without third-party recommendations. Neither choice guarantees a faster page or more conversions: test the page your visitors actually use.
Choose the embed method for the page’s purpose and the delivery work your team can support.
How to embed a YouTube video
YouTube is a straightforward choice if your video is already public there or you want viewers to discover it on YouTube as well as your site.
- Open the video on YouTube and select Share, then Embed.
- Copy the provided code.
- Paste it into a custom HTML or embed area on your page. Many site builders also accept the video URL in a dedicated YouTube or video block.
- Publish or preview the page and test playback.
A basic iframe looks like this:
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/VIDEO_ID"
title="Product demonstration"
loading="lazy"
allowfullscreen>
</iframe>
Replace VIDEO_ID with the ID from your video and give the iframe a descriptive title. For an offscreen embed, loading="lazy" lets the browser defer loading it until it is near the viewport. Follow any additional permissions in YouTube’s generated code if your video needs them.
The tradeoff is control. YouTube’s player carries its branding and may show ads or related videos. YouTube also offers a privacy-enhanced embed using youtube-nocookie.com; it changes personalization behavior but does not by itself eliminate requests to Google. For more on that choice, see why YouTube embeds can affect your website and our privacy-enhanced embed guide.
How to embed a Vimeo video
Vimeo also supplies a player you can place in a page with an iframe or a supported video block.
- Upload the video to Vimeo or open an existing video you have permission to share.
- Find its Share or Embed option and copy the embed code.
- Paste the code into your site’s HTML or embed area, or use the video URL in a supported Vimeo block.
- Check the published page, particularly if the video has privacy or domain restrictions.
Vimeo can be a good fit when presentation and player settings matter. Review the current plan terms before committing: available customization, storage, and usage allowances can differ by plan. Our Vimeo embed guide covers the setup in more detail.
How to embed video in HTML with the video element
The HTML5 <video> element displays a video file directly in the browser. Unlike a YouTube iframe, it points to a media file you make available rather than loading YouTube’s player.
<video
controls
preload="none"
poster="/images/demo-poster.jpg"
width="1280"
height="720">
<source src="/videos/demo.mp4" type="video/mp4">
<track
kind="captions"
src="/captions/demo.vtt"
srclang="en"
label="English">
Your browser does not support embedded video.
</video>
Replace the file paths with your own video, poster image, and caption file. controls gives visitors playback controls; poster displays an image before playback; and preload="none" asks the browser not to preload the video file. Browser behavior can vary, so confirm the result in a network test. The MDN video element reference explains the available attributes.
Make the player fit smaller screens with CSS:
video {
max-width: 100%;
height: auto;
}
The markup is only part of the job. You also need a video file encoded for your audience, a host that can serve it reliably, and enough capacity for your traffic. A large MP4 on ordinary web hosting may cause slow starts or use more bandwidth than expected. A CDN and appropriate video formats can help, but they require setup and monitoring.
Use HTML5 when that control is valuable and your team can maintain delivery. For a closer look at the work involved, read why self-hosted video can become difficult at scale and the HTML5 video player guide.
How to use a generic iframe from another video host
Many business video providers supply an iframe even if they do not have a plugin for your site builder. The process is usually the same:
- Upload or select the video in your provider’s dashboard.
- Set the player, privacy, and caption options you need.
- Copy the provider’s embed code.
- Paste it into a custom HTML or embed area.
- Preview the page and test playback, captions, mobile sizing, and any domain restrictions.
Keep the provider’s required attributes intact. If you edit the code, use a descriptive iframe title and check the MDN iframe reference for loading and permission attributes.
Before choosing a provider, ask whether its player supports captions, responsive sizing, the branding controls you need, and a way to defer offscreen embeds. Also check whether it supplies video structured data or expects you to add it. An iframe alone does not tell you which of those features are available.
How to embed video with a managed host
A managed video host stores and delivers the video and provides a player for your page. Depending on the provider, you might add it with an iframe, a site-builder integration, or a script and custom tag.
This approach is useful when your team wants control over the page experience without operating its own video delivery infrastructure. Compare player branding, captions, analytics, privacy settings, plan limits, and actual page performance before choosing a host.
Check which player, loading, and schema settings your host offers and how they apply to your site.
SmartVideo offers a WordPress integration and a script-plus-tag approach for other websites. A tag can look like this:
<smartvideo
src="path/to/my/video.mp4"
width="1280"
height="720"
class="swarm-fluid"
controls
playsinline>
</smartvideo>
The tag requires the SmartVideo script and a valid video source; it will not work by itself. Use the installation instructions and embed code supplied for your account, then test the result on your published page.
Want an ad-free player on your website? SmartVideo handles delivery and offers a branded player without YouTube recommendations. See how HTML video hosting works with SmartVideo, then try it on your own page.
How to embed video in WordPress
WordPress supports several approaches, so choose the one that matches where the video is hosted.
- Open the post or page in the editor and add a block where the video should appear.
- For YouTube or Vimeo, add the corresponding embed block or paste a supported video URL and confirm it becomes an embed.
- For an iframe from another provider, add a Custom HTML block and paste the provider’s code.
- For a file hosted in your WordPress media library, add a Video block and select the file. For a managed host, follow its plugin instructions and use its block or shortcode.
- Preview the page at desktop and mobile widths, then publish and test it.
A dedicated WordPress block can place the player and its settings inside the editor.
A video file in the media library still needs to be delivered to every viewer. Check your web host’s capacity and bandwidth terms before using that approach for large files or high-traffic pages. For more options, see the WordPress video hosting guide and considerations before uploading video directly to WordPress.
How to embed video in Shopify
Shopify themes and editors offer different video sections, so the exact controls depend on the theme and where the video will appear.
- Open the relevant page, product, or theme template in your Shopify admin.
- If your theme offers a video section or block, add it and enter the supported video URL.
- If your provider gives you embed code, use an HTML-capable content area or a custom code section supported by your theme. Follow the provider’s instructions if a site-wide script is required.
- Save and preview the correct product or page template. Check desktop and mobile, then test the published page.
A product-page video should not obscure the price, purchase controls, or other content shoppers need. Test the page with the video in place, especially if the template also loads product images and apps. The Shopify video hosting guide covers the store-specific tradeoffs in more detail.
How to embed video in Squarespace
Squarespace offers video blocks for supported providers and code blocks for custom embeds. Available code and script options can depend on your plan and site configuration.
- Edit the page and add a Video block where the video should appear.
- Enter a supported YouTube or Vimeo URL, or use the block’s available upload or embed options.
- For a provider’s custom embed, add a Code block and paste its snippet. If the provider requires a separate site-wide script, add it through the appropriate code injection setting when available on your plan.
- Save the page and test the published version, including on a phone.
A code block that appears in the editor does not guarantee every script will run there, so check the live page as well. For more detail, see how to add video to a Squarespace site and how to make a video autoplay on Squarespace.
How to embed video in Webflow
Webflow supports video elements for common providers and custom code for other embeds.
- Open the page in the Designer and add a Video element for a supported YouTube or Vimeo URL.
- For another provider’s iframe or an HTML5 video element, add a custom code embed and paste the code.
- If your provider requires a script outside the embed, follow its instructions for adding custom code to the page or site.
- Publish and test the live page. Confirm the player fits its container and that any required scripts load.
Check that the published version behaves as intended at each breakpoint. If you use SmartVideo, follow the Webflow installation guide for the provider-specific setup.
How to embed video in a raw HTML website
For a hand-coded site, choose the code that matches your host:
- Obtain the provider’s iframe or script and player tag, or prepare an HTML5
<video>element pointing to your file. - Paste the player markup inside the page’s
<body>where the video should appear. - Add any required provider script according to its instructions.
- Size the player for its container, provide captions, and publish the page.
- Test playback, resizing, keyboard controls, and loading behavior.
For a responsive iframe, place it in a container and give that container the video’s aspect ratio. Use the ratio that matches your video; 16:9 is common.
<div class="video-frame">
<iframe
src="https://www.youtube.com/embed/VIDEO_ID"
title="Product demonstration"
loading="lazy"
allowfullscreen>
</iframe>
</div>
.video-frame {
aspect-ratio: 16 / 9;
width: 100%;
}
.video-frame iframe {
width: 100%;
height: 100%;
border: 0;
}
For an above-the-fold video that visitors need immediately, test before applying lazy loading. Deferring important content can delay its appearance or make the experience feel slower.
Does embedding video slow down your website?
It can. A video embed may add player scripts, images, network requests, and media downloads to a page. The effect depends on the provider, the embed configuration, the video’s position, and the visitor’s device and connection.
A native HTML5 embed with a poster and preload="none" may make fewer initial requests than a full third-party player, but that is not guaranteed to produce the best playback experience. A managed player also has its own assets and configuration. Measure both initial page load and how quickly playback starts.
| What to check | Why it matters | What to try |
|---|---|---|
| Largest Contentful Paint | A large poster or competing player requests may delay visible content | Optimize the poster and compare page tests with and without the embed |
| Offscreen player requests | Several below-the-fold embeds can load before anyone sees them | Test native iframe lazy loading or a click-to-load placeholder |
| Video start time | A page can load quickly while playback starts slowly | Test playback on a mobile connection and review encoding and delivery |
| Layout shifts | A player without reserved dimensions can move surrounding content | Set dimensions or an aspect ratio before the player loads |
| Multiple embeds | Each player may add work and requests | Test the page with the actual number of videos it needs |
A click-to-load placeholder can defer the full player until someone asks to watch. If you use one, make the play control accessible by keyboard and give it a clear label. For implementation options, see web.dev’s guide to lazy-loading video.
Page speed has business value beyond video. In a study commissioned by Google and conducted by 55 and Deloitte, researchers reported an association between a 0.1-second speed improvement and higher retail conversion and order value; that finding does not predict the effect of changing a particular video embed (web.dev).
Check privacy and consent behavior
Third-party players can make requests to their providers and may use cookies or similar technologies. The timing and behavior depend on the provider, embed settings, and whether the visitor starts playback.
Review the provider’s current documentation and your site’s consent setup. If your site requires consent before a player loads, test that the player and its network requests respect the choice. A privacy-enhanced setting is worth checking, but it should not be treated as a substitute for reviewing the complete setup.
How does embedding video affect SEO?
A video can make a page more useful, but adding an embed does not guarantee a ranking improvement or a video result. Google needs to discover the page and video, understand their relationship, and be able to access the relevant resources.
For an important video:
- Give it a clear title, an appropriate thumbnail, and useful surrounding text.
- Provide a transcript or summary where it helps visitors understand the content.
- Make sure the page is indexable and the video is accessible to search engines.
- Add accurate
VideoObjectstructured data when appropriate, including the properties Google requires or recommends for the result you want. - Use Search Console to investigate indexing issues.
Google’s video SEO guidance explains the requirements and notes that a watch page where the video is the main content is relevant for video indexing. Structured data helps describe a video; it does not guarantee a rich result.
You can add page context and structured data around a YouTube embed too. Hosting the video elsewhere does not automatically make your page rank, and some managed hosts generate schema while others require configuration or leave it to you. Check the rendered page and avoid adding conflicting duplicate markup. For implementation detail, see the guides to video schema markup and video sitemaps.
Make the player accessible and usable
A working embed should be usable by people who cannot hear the audio, use a mouse, or comfortably view a wide desktop layout.
- Provide accurate captions. Upload or enable a caption track and review it for names, technical terms, and meaningful sounds.
- Test keyboard controls. A visitor should be able to reach and operate the player without a mouse.
- Give iframes descriptive titles. “Product setup walkthrough” is more useful than a generic “video player.”
- Keep controls visible on small screens. Test the actual page at a phone width.
- Use autoplay carefully. Browsers often restrict autoplay with sound. For decorative muted video, avoid making playback the only way to understand essential content and provide appropriate controls where needed.
A transcript can complement captions by giving readers a way to scan or search the content. Accessibility depends on the complete experience, so test the player and its content rather than assuming a host makes the page compliant.
FAQ
Does embedding video slow down your website?
It can. A player may load scripts, thumbnails, and media that compete with the rest of the page. Measure the published page, reserve space for the player, and consider deferring offscreen embeds. Also test playback start time so that an optimization does not simply shift the delay to the viewer’s click.
Is it better to embed YouTube or host video yourself?
YouTube is convenient when free hosting and public discovery matter. Self-hosting offers direct control over the file and player but makes you responsible for encoding, bandwidth, and delivery. A managed host is another option if you want a controlled player without managing all of that infrastructure.
How do I embed video without YouTube branding?
Use a video file with an HTML5 <video> element or choose a host that offers a player without YouTube branding. Check the host’s plan and player settings for any other branding, ads, or links before publishing.
What is the HTML code to embed a video?
Use a <video> element with a source URL for a directly hosted file, or paste an iframe supplied by a video provider. A basic native example is <video controls src="/videos/demo.mp4"></video>. Add a poster, captions, and responsive sizing for a more complete implementation.
How do I embed a video in WordPress?
Add a supported YouTube or Vimeo URL in an embed block, place provider code in a Custom HTML block, or use a video hosting plugin’s block or shortcode. Preview and test the published page, especially if your provider requires a separate script.
Can you embed Vimeo videos without ads?
Vimeo offers ad-free video playback, though player features and customization depend on the plan. Check Vimeo’s current terms and the video owner’s privacy settings before choosing it for your site.
What is the difference between embedding a video and uploading one?
Uploading puts a video file into a storage location, such as your website’s media library or a video host. Embedding places a player on a page so visitors can watch it. You may upload a file to one service and then embed its player on another site; a page can also display a file on its own server through an HTML5 video element.
Does embedding a YouTube video help SEO?
It can make a page more useful to visitors, and Google may be able to discover and understand the embedded video. It does not guarantee higher rankings or a video result. Give the page useful context and follow Google’s video indexing and structured data guidance where applicable.
How do I embed video in Squarespace or Shopify?
Use a video block or section for a supported video URL. For another provider, use an HTML-capable area or custom code feature supported by your plan or theme, and add any required script according to the provider’s instructions. Test the published page on mobile.
How do I embed video in Webflow?
Add a Video element for a supported provider URL, or use a custom code embed for an iframe or HTML5 video. If the player needs a separate script, install it according to the provider’s instructions and test the published page.
Can I embed a video without autoplaying?
Yes. Most embeds can wait for a visitor to press play. For an HTML5 <video> element, leave out the autoplay attribute. For a hosted player, turn autoplay off in the provider’s settings or use the embed code without an autoplay parameter.
Choose the embed that fits the page
Start with the simplest method that meets the page’s needs. YouTube and Vimeo make it easy to add an existing public video. HTML5 gives you direct control when you can support the delivery work. A managed host can take on that work while giving your site a more controlled player.
Whichever route you choose, test the complete page: check mobile sizing, captions, initial load, playback start, and the next action you want visitors to take. SmartVideo’s 14-day free trial lets you test an ad-free, branded player on your site. A card is required; there is no charge until day 15.