Skip to main content

Using The width Property

If the width property is set to 100%, the video player will be responsive and scale up and down.

Note that the video player can be scaled up to be larger than its original size. In many cases, a better solution is to use the max-width property instead.

Example

Prompt
Create a page with a video element that uses width: 100% and height: auto to make it responsive. Use any sample video source (e.g. a PromptCookbook sample video). The video should scale up and down with the browser window.
Output: complete HTML page

Using The max-width Property

If the max-width property is set to 100%, the video player will scale down if it has to, but it will never scale up to be larger than its original size.

Example

Prompt
Create a page with a video element that uses max-width: 100% and height: auto to make it responsive. The video should scale down when needed but never grow larger than its original size.
Output: complete HTML page

Add a Video to the Example Web Page

You can add a video to your web page and make it responsive by setting width to 100% and height to auto. The video will resize to always take up all the available space.

Example

Prompt
Create a simple web page layout with a header, navigation, content section, and a responsive video using width: 100% and height: auto. The video should always fill the available space in the content area.
Output: complete HTML page