Categories
Code

Background Video with CSS

The YouTube Fan Fest website is a good example of a web page that uses background video to add life to an otherwise boring page. The HTML5 video autoplays in the background in a loop. The video is however hidden when the website is viewed on a mobile device and a static background image is used instead.

Here’s the HTML code:

 
    
  

The site uses CSS media queries to hide the video element on mobile devices (device width < 768 pixels).