HTML5 Video is a powerful tool.  Done well, videos can draw attention, set a mood, or explain a topic.  Video banners are especially good at those first 2 points.

Making a good video banner requires more than slap a <video> tag on a page and call it good.

In this article we’re going to explain everything you need to know to make great HTML5 Video banners. Including:

  • HTML Code for adding the video
  • Auto-playing on mobile devices
  • What kinds of videos work best
  • Compressing videos (so they load super fast)
  • Advanced effects with java-script.
  • Adding Video Key frames with Handbrake.

Tip #1: Keep Files Small As Possible

Large video files are the enemy.

When making a video banner, don’t upload a 50 Megabyte file!  In fact, don’t even upload a 5 MegaByte file.


In a word… Slowdowns.  When you self host a video, every person that comes to your website has to download the file.  Hosting large video files on your website can slow down the entire website across the board.

What if I host it on an external server?

You can potentially host your video on a service like Cloudinary or other media hosting services, but even then, keeping the file small will insure people will see it in a timely manner.

Keep your videos tiny or many visitors will just see a black box…

How Small Should It Be?

Whenever possible, try to keep your video under 1 Megabyte.  If you can’t keep it under 1MB at least shoot for less than 2MB.

Does It Really Need To Be That Small?

I can hear some of you saying “It’s 2018. Everybody has broadband now and my 30MB file loads instantly.”

This is a common mistake.

Novice developers will see their video load instantly and assume everything’s right as rain (until a month later when they load the site on computer that’s never been to their website before).

The reason your 30MB file loads instantly is because it’s already cached on your computer.  Even on broadband, many users wont see the video for 10-45 seconds.

By then, most of your visitors will have already scrolled down the page, or clicked away, never noticing your amazing video.

But how exactly do you get your files so small?


Tip #2: Use “HandBrake” for Compression

HandBrake is a free video compression program and it’s amazing.

The example video above is 525kb and still looks good. 

Video exported from Adobe Premiere or other video editing software can run anywhere from 10MB to 10GB.   This if fine for many situations but not for web banner or anything similar.

So export your video from Adobe Premiere (or whatever program you use to edit videos) at a nice high quality.  Then compress it through Handbrake.

Download HandBrake (for free)


Tip #3: Choose Videos with Subtle Movement

Videos with subtle movements compress much better than a videos where everything is constantly changing.
Note: If you don’t see any movement, refresh your browser.

Quick Intermission Poem:

If upon a smartphone
this article you’ve read,
one video will play

while the other one be dead.
For there is a rule
that I recently have found
that apparently all smartphone-type
are bound.
One video only
can play at a time
which is why I’ve resorted
to writing this rhyme
I wrote this short poem
to fill-in some space
So each little video
may play in
its place.

Okay, back to the article…

This video looks nice, but its not an ideal video banner. The panning camera means the entire shot is constantly changing. This makes it hard to compress. While the waterfall video above has large parts of the frame that don’t change.


Tip #4: Stay Around 8-16 Seconds Long

In general, keep your videos around 8-16 seconds long.

You won’t be able to compress a 2-minute video down below 1 or 2 MB (and still look good).

Every video is a little different, but 8-16 seconds tends to be the sweet spot.  The loops aren’t so short as to be annoying, but still short enough for effective compression.


Trick #5: Simple HTML5 Video Code

Once you’ve made your video, you need to place it play on the webpage.

To keep things easy, I’ve prepared some simple code to add an HTML5 Video to your webpage.

Simple Looping HTML5 Video

Let’s say you want to have a simple video that automatically plays and loops (like the example above).

<video autoplay loop muted controls width="100%" height="auto"

If you copy the above code.  To use your own video, simply change the URL (in orange) to your own file.

Remove the Controls

Delete the word “controls” (highlighted above in green) to remove the playback controls.

This gives a feeling similar to an animated gif, and a more seamless experience.

Example with no controls

Add a “Poster” To Make a Preview of Your Video

Even with a well compressed video, it may still take a few seconds to load (especially on slow connections).

Adding a poster attribute to your code, will give people something to look at while your video loads, so they don’t have to look at a black box.

<video autoplay loop muted controls width="100%" height="auto" 


Tip #6 Looping Part of a Video JavaScript

Seeing the girl open the tent over and over, can start to feel old.  Let’s have her open it just once by removing the word “loop” from the code.

But then we loose all motion after the first play-through.  Let’s keep the movement going by adding some java-script trickery.

Loop the last 5 seconds of the video


Watch the play-head and notice what happens…

Instead of looping the entire video, let’s just loop the last 5 seconds.

This can be accomplished with the following code:

<video autoplay playsinline muted controls width="100%" height="auto" src="" poster="" ></video>
var Video = document.querySelector('video');
Video.onended = function(e) {
  Video.currentTime = 4;;

This code is actually pretty simple.  It basically says “When the video ends… move the play-head to the 4-second mark.  Then play the video.”  This results in an endless loop.


Play A 2nd Video After The 1st Video Ends

Sometime you might want to play 2 videos in sequence, like this stylish video banner on (designed by the web firm

When I saw this website, I took some time to dissect it and recreate it.  You can look at the code here.


Tip #7: Make AutoPlay Work on Mobile Devices

By default, auto-play is disabled on mobile-devices.  Users must click on the video to play it, and then it opens the video in full-screen.  This makes sense for stand-alone videos, but not when you want to use animation in your website layout.

You COULD use an animated gif, but animated gifs tend to be large and download slowly.  Using an HTML5 video will download faster and use less battery on smartphones.

The Rules…

To keep people from abusing the technology, any videos that plays automatically cannot play sound (which makes sense because nobody wants to go to a website and have unsolicited videos yelling at them).

To make your video play on smartphones add  the following attributes to your video tag:

  • playsinline
  • muted
<video autoplay playsinline muted controls width="100%" height="auto" src="" poster="" ></video>

“playsinline” allows the video to play without going into full-screen mode, and “muted” turns off the sound (in case the video has any).

One Video on Screen at a Time

On smartphones, you can only have 1 auto-play video on screen at a time.

Bonus Tip – Keyframes

Sometime you may need to tightly control the playback of a video.

For example, take a look at these two videos. Try scrubbing very through both videos quickly.

Video 1 No Keyframes

Video 2 – Keyframes

When scrubbing through the first video quickly, the video has to stop and ‘seek’ before continuing to play.  But scrubbing through the second video happens almost instantly.

Why is this?

The second video was compressed using additional key frames.  

How To Add Keyframes

Open your video in Handbrake.  On the “Video” tab, under “Extra Options” type in keyint=8 . This will place a keyframe every 8 frames.

Things to Keep In Mind

Adding more key frames will make your video file larger.  The Earth video without keyframes is 1.6MB while the key frame version is 3.6MB

After some experimentation with my Earth video, every 8 frames seemed to be the sweet-spot. 


1 Comment
  • Administrator says:

    Wow, this is some really good information. Thanks for sharing, Steve!