Altering the Width and Height of the Video
In our first example, we showed how you could embed a video
without changing the default width or height. However, there are many
good reasons why you might want to change the default width and height
of a video in the HTML page, such as fitting it into a particular part
of the page or enlarging it so that it is easier to see. Similar to
embedding an image into HTML with the <img> tag, a video will scale to
whatever width and height you provide in the <video> tag. Also, like with the
<img> tag, this scale does not
affect the size of the object downloaded. If the video is 5 megabytes at
640×480, it will still be 5 megabytes when displayed at 180×120—just
scaled to fit that size.
In Example 6-3 (CH6EX3.html), we have scaled the same video to three different sizes and displayed them on the same page. Figure 6-3 shows what this looks like in HTML (again, rendered in the Google Chrome browser).

Figure 6-3. Controlling video width and height in the embed
Example 6-3. Basic HTML5 video in three sizes
<!doctype html><htmllang="en"><head><metacharset="UTF-8"><title>CH6EX3: Basic HTML5 Video: 3 Sizes</title></head><body><div><videoautoplayloopcontrolswidth="640"height="480"id="thevideo"><sourcesrc="muirbeach.webm"type='video/webm; codecs="vp8, vorbis"'><sourcesrc="muirbeach.mp4"type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access