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

TOPICS

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. 

Latest in Video Editing Software
How to make GIF&#039;s using shortcuts
How to make a GIF on iPhone or iPad
Premiere Pro AI feature shown at MAX
Premiere Pro's new tools are exactly what AI should be used for
A screenshot from LumaFusion for iOS
LumaFusion for iOS review: multicam editing gives video app a pro toolset
A screenshot from DaVinci Resolve Studio 18.5 on a computer screen
DaVinci Resolve Studio 18.5 review: video editor takes another step forward
Wondershare Filmora video aesthetic
How to colour grade like a pro with Wondershare Filmora 12
Final Cut Pro for iPad
Apple's Final Cut Pro for iPad pricing is causing controversy. Is it worth it?
Latest in How to
Rob Redman&#039;s snowy image illustrates the AE tutorial: TDW313.PT_AE_Snow.indd
How to create realistic snow with particle systems using After Effects
Ivan Mironenko ZBrush character tutorial
Craft a game-ready character asset using ZBrush and Substance 3D Painter
Oliver Schümann ZBrush bizarre baby tutorial
Create a bizarre baby sculpture in ZBrush
Alireza Khoshpayam arch-viz tips
Speedy tips to create beautifully photoreal archviz using 3ds Max and Corona
Maya 3D abstract strands tutorial
How to easily create complex and abstract animation using Maya
Whiskytree battle damage effects tutorial
Create gnarly battle damage for vehicles using a mix of Maya and Nuke