Adding videos to HTML sites is a relatively simple process whether you’re a beginner or a seasoned coder.
How you want to host the video will determine the best approach to adding it to your site. For example if the video is substantial in data size this will likely mean that for a reasonable user experience you have to host it with an external video hosting platform such as Youtube or Vimeo. However if you have considerable server resources and or the video isn’t particularly large then you may want to host it directly on your site.
Hosting a video directly on your site:
This can be achieved by using the <video> tag within HTML for example <video> < source src=”avideo.mp4”> <source src=”avideo.webm”> </video> This displays a video in two formats mp4 and webm which is important for browser optimisation.
You can add additional parameters to the video display such as setting height and width, as well as messages that are displayed if the video isn’t shown and features such as autoplay.
For example:
<video width=”500” height=”500”>
<source src=”avideo.mp4”>
<source src=”avideo.webm”>
</video>
The above example uses the same videos as demonstrated at first however it assigns a height and width to them.
Further expanding on this you can add text to be displayed if the video doesn’t load for example:
<video width=”500” height=”500”>
<source src=”avideo.mp4”>
<source src=”avideo.webm”>
Lorem Ipsum Dolor Sit Amet
</video>
You can also add controls to your video by using the ‘controls’ attribute. For example:
<video controls width=”500” height=”500” >
<source src=”avideo.mp4”>
<source src=”avideo.webm”>
Lorem Ipsum Dolor Sit Amet
</video>
Hosting a video with Youtube:
If you’ve decided that the video is too large to host on your own site or you may want to use one of the most popular video platforms on the internet to host your video.
To do this you’ll need to have the video uploaded to Youtube. From here you can select share and then embed which will provide you with the iframe code for the video.
Hosting a video with Vimeo:
Another popular video hosting platform is Vimeo, where you can also generate an iframe to add directly to the HTML within the page. Simply click the share button that looks like a paper plane and then select the embed option to get the full iframe code.
Further reading:
Adding Youtube videos to a WordPress website
Adding Vimeo videos to a WordPress site
We hope this helps you with adding video directly to your HTML site, we’d appreciate a share or any comments if you found this useful, thanks!








