Technology

How to add webm to my site? Here are 5 Ways

Written by Eric · 1 min read >
How to add webm to my site

Adding a WebM video to your website can be done in multiple ways, depending on how you want to display it. Here are 5 methods:

1. Using the <video> Tag (Recommended)

The simplest way to embed a WebM video is by using the <video> element in HTML:

<video controls width=”600″> <source src=”video.webm” type=”video/webm”> Your browser does not support the WebM format. </video>
  1.  Adds playback controls (play, pause, volume, etc.).
  2. Adjust the width of the video.
  3. Defines the WebM video file.
  4. The fallback text is shown if the browser does not support WebM.

2. Adding WebM with Autoplay & Loop

If you want the video to play automatically and loop:

<video autoplay loop muted playsinline> <source src=”video.webm” type=”video/webm”> </video>
  1. Starts playing the video automatically.
  2. Restarts the video after it finishes.
  3. Mutes the video (some browsers require muted autoplay).
  4. Ensures playback inside mobile browsers instead of full screen.

3. Using WebM as a Background Video

If you want to use WebM as a full-screen background:

<video autoplay loop muted playsinline style=”position: fixed; right: 0; bottom: 0; min-width: 100%; min-height: 100%;”> <source src=”background.webm” type=”video/webm”> </video>
  1. This ensures the video fills the screen.

4. Embedding WebM via JavaScript

You can dynamically load a WebM video using JavaScript:

<video id=”myVideo” controls> </video> <script> document.getElementById(“myVideo”).innerHTML = ‘<source src=”video.webm” type=”video/webm”>’; </script>

5. Hosting WebM on a CDN (Optional)

If you don’t want to store the video on your server, upload it to a CDN (like Cloudflare, BunnyCDN, or AWS) and use the direct URL:

<video controls> <source src=”https://cdn.example.com/video.webm” type=”video/webm”> </video>

Browser Compatibility

Most modern browsers support WebM (Chrome, Firefox, Edge). However, Safari on iOS does not support WebM. To ensure compatibility, provide an MP4 fallback:

<video controls> <source src=”video.webm” type=”video/webm”> <source src=”video.mp4″ type=”video/mp4″> Your browser does not support WebM or MP4. </video>
What is a Mobile Service Manager

What is a Mobile Service Manager?

Eric in Technology
  ·   1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *