Video Coding

Home❯Coding Introduction❯Responsive

Responsive Design (for Mobles, etc.)


This can be achieved by using CSS. In this simple example, we've styled the IFRAME to be 100% of the width and set aspect-ratio to 16/9 because that's the usual aspect ratio of Youtube videos. This works fine on mobiles but many desktops have landscape displays and using 100% of the width willl result in the video being too tall. This isn't a (big) problem on our site becaise we limit our page widths to 900 pixels anyway:
 
<body style="margin: auto; max-width: 900px">...
 
If that approach isn't suitable perhaps because you want users to have the whole width of a large screen available to show your site, you may need to use "Media Queries" to style the IFRAME to something less than 100%. (We don't cover Media Queries yet).
 
Here's the main code:
 


Last modified: 11 October 2025, 5:07pm