Add HTML5 video to your website

  • Knowledge needed: Basic HTML5 and CSS
  • Requires: A video in Ogg Theora and MP4/H.264 video (we also show you how to convert to the Ogg format if you need it), a modern web browser (Opera, Firefox, Chrome, Safari) and a text editor
  • Project Time: 1 hour
  • Support file

Want to add HTML5 video to your site? You can do this as easily as placing images with an <img> element – and in this tutorial, we’ll show you how the magic is done.

In the example code below, the src attribute points to the video file and controls indicates that we want the browser to show control buttons (play/pause, volume and so on). The value of the optional poster attribute is the path to the static image that the browser will show while the video is loading and before a user hits play. It’s a good idea to pick an appealing frame that will persuade users to view the video. If you don’t use poster, the first frame of the video will be displayed. The code between the opening and closing video tags is fallback content for browsers that have no HTML5 video support.

Thank you for reading 5 articles this month* Join now for unlimited access

Enjoy your first month for just £1 / $1 / €1

*Read 5 free articles per month without a subscription

Join now for unlimited access

Try first month for just £1 / $1 / €1

The Creative Bloq team is made up of a group of design fans, and has changed and evolved since Creative Bloq began back in 2012. The current website team consists of eight full-time members of staff: Editor Georgia Coggan, Deputy Editor Rosie Hilder, Ecommerce Editor Beren Neale, Senior News Editor Daniel Piper, Editor, Digital Art and 3D Ian Dean, Tech Reviews Editor Erlingur Einarsson and Ecommerce Writer Beth Nicholls and Staff Writer Natalie Fear, as well as a roster of freelancers from around the world. The 3D World and ImagineFX magazine teams also pitch in, ensuring that content from 3D World and ImagineFX is represented on Creative Bloq.