Creating a fullscreen HTML5 video background playlist

Going back to one of my previous posts I shared some information and demonstrated how to create a fullscreen HTML5 video background using only CSS.

If you haven’t yet managed to read that one, please go ahead and take a few minutes to do so now, before reading with this post. It’ll be easier for you to follow along since this post starts essentially where the first one left off.

In this post I’ll simply show you how to create a video background playlist.

Since the HTML/CSS are mostly the same, I’ll just paste the final code here and point out the changes.

The .fullscreen-bg div has a new id.
There’s a new section containing links to 3 new videos. This will serve as our playlist.

Besides a selection of small changes to the content styling, the only notable change in the stylesheet is the following piece of code:

Looking at the previous post we didn’t have any JavaScript. We managed to pull off a fullscreen video background using only CSS. Unfortunately that won’t be the case with our background playlist. In order for our playlist to work well we’ll need the following block of code. Remember, it doesn’t actually matter if you add it within a script element at the bottom of the .html or in its seperate .js file linked in the head of the page.

Please go ahead and check out a working example: DEMO PAGE

NOTE: Although the fact of having multiple videos playing in the background sounds kind of nice, you should always be mindful of the website performance. If you plan to add more than one video to your website try to reduce the file size as much as possible as this will certainly help you to avoid any performance issues.

About Luka Čavka

I’m a front-end developer from Split, Croatia, with a passion for responsive web development, especially HTML and CSS coding. During 7+ years of professional experience I have worked with clients from various fields and have published more than a few hundred websites. In my spare time I enjoy tinkering with new front end tools/techniques and having a beer (or two) at the local pub.