All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Understanding Video Aspect Ratio Challenges in Web Development

By

PaulHoule

5mo ago· 9 min readenInsight

Summary

The article discusses technical challenges with video embedding on web pages, specifically focusing on aspect ratio issues and cumulative layout shift. It explains how specifying aspect ratios for videos should theoretically prevent layout shifts during page loading, but reveals that some videos don't fit their allocated spaces properly due to discrepancies between stored frame dimensions and display aspect ratios. The content provides technical insights into web development practices for video embedding and layout stability.

Key quotes

· 5 pulled
When I embed videos in web pages, I specify an aspect ratio. For example, if my video is 1920 × 1080 pixels, I'd write: <video style='aspect-ratio: 1920 / 1080'>
If I also set a width or a height, the browser now knows exactly how much space this video will take up on the page – even if it hasn't loaded the video file yet.
When it initially renders the page, it can leave the right gap, so it doesn't need to rearrange when the video eventually loads. (The technical term is 'reducing cumulative layout shift'.)
That's the idea, anyway. I noticed that some of my videos weren't fitting in their allocated spaces.
When you want to get the dimensions of a video file, you probably want the display aspect ratio. Using the dimensions of a stored frame may result in a stretched or squashed video.
Snippet from the RSS feed
When you want to get the dimensions of a video file, you probably want the display aspect ratio. Using the dimensions of a stored frame may result in a stretched or squashed video.

You might also wanna read