A business displays a product video above the link to the assembly instructions. When the page loads, the link initially appears directly below the headline. Then, a wide video player appears and shifts the link downward. A stable container ensures that space for the preview and player is reserved in advance, so it's available when the first piece of page content appears.
Determine the area of the real player
Check the width and height required by the player in the intended layout. A video area with a 16:9 aspect ratio is 202.5 CSS pixels high when the width is 360 CSS pixels. Actual embedding may require additional space for controls, captions, or a notice. Reserve this space in the final layout where these elements will appear.
In CSS, a container with a predefined aspect ratio and automatically calculated height can be created using the aspect-ratio property. An embedded player can adjust to the container if the embedding method supports it. The specifications for iframe, thumbnail, and container must be consistent within the stored page code. The browser calculates the height based on the actual width of the container.
CSS Working Group · Preferred aspect ratios during size calculation
Compare the poster, loading state and final player
- Select the next element below the video, for example the link to the assembly instructions. Check its position both before and after the video player has loaded.
- Repeat the test on both narrow and wide screens. Slow down loading in your test environment to ensure you can see the previous state.
- If the video loads only when scrolling or upon clicking, verify this step separately. The placeholder should occupy the same space as the embedded version.
- Check what appears when a loading error occurs. The alternative text and the video link should remain visible within the designated area.
web.dev identifies embeds without defined dimensions as a possible cause of layout shifts. For third-party elements with variable heights, proper sizing may depend on width. In the specific example, check the position of the link within the same viewport area. Note additional shifts separately, such as those caused by a late-loading font.
web.dev · Reserve space for later-loaded third-party embeds
web.dev · Investigating layout shifts and their causes