Video Embed
What YouTube Video Embedding Is
Embedding a YouTube video means placing a playable YouTube video player directly inside a webpage using an HTML <iframe> element. The video streams from YouTube's servers — you don't host the video file yourself. Embedded videos look and behave like the native YouTube player but appear within your page's layout. Views from embedded players count toward the video's YouTube view count and are tracked in YouTube Analytics.
The Embed Code Structure
YouTube's standard embed code looks like: <iframe width="560" height="315" src="https://www.youtube.com/embed/[VIDEO_ID]" frameborder="0" allowfullscreen></iframe>. The key part is the /embed/ URL path followed by the video ID. This is different from the regular watch URL (watch?v=). The embed URL accepts query parameters that control player behavior — for example, ?start=90 starts playback at the 90-second mark, ?autoplay=1 starts automatically, and ?mute=1 mutes audio on load.
Key Embed Parameters
The most useful embed parameters are: start and end to define a playback range in seconds; loop=1 with playlist=[VIDEO_ID] to loop the video; controls=0 to hide the player controls; rel=0 to prevent related videos from other channels appearing after playback; and modestbranding=1 to reduce YouTube logo visibility. Privacy-enhanced mode uses youtube-nocookie.com instead of youtube.com to avoid setting cookies until the viewer plays the video.
Making Embeds Responsive
The default embed uses fixed pixel dimensions (560×315), which breaks on mobile. The standard responsive approach wraps the iframe in a container div with position: relative; padding-bottom: 56.25%; height: 0; and styles the iframe with position: absolute; top: 0; left: 0; width: 100%; height: 100%;. This maintains a 16:9 aspect ratio at any screen size. Many CSS frameworks and CMS platforms include responsive embed utilities that handle this automatically.
Who Can and Can't Embed Videos
Most public YouTube videos can be embedded by anyone. However, creators can disable embedding for their videos in YouTube Studio, in which case the embed will display a "Video unavailable" error. Some music videos and licensed content may also be restricted. Age-restricted videos cannot be embedded. Live streams can be embedded while they're live. Before building a page around an embedded video, verify that embedding is actually enabled for that specific video.
Performance Considerations
Each YouTube embed loads the full YouTube player JavaScript, which adds roughly 500KB–1MB to your page load. For pages with multiple embeds or that need fast load times, use a "lazy embed" approach: show the video thumbnail as a clickable image and only load the actual iframe when the viewer clicks it. This is called a facade pattern and can reduce initial page load time significantly on video-heavy pages.
Work with YouTube video links, embeds, and metadata using YouTube Utils — video tools for creators and developers.