How to embed an MP4 video on a web page using the video HTML tag

In this brief tutorial, we consider a basix example of adding an MP4 video to a web page ...

Home Programming Examples HTML Examples → How to embed an MP4 video on a web page using the video HTML tag
how to embed an mp4 video on a web page using the video html tag


To embed an MP4 video in a web page, you can use the special HTML video tag.

Here you can find an example of it:


<video width="100%" autoplay>
<source src="your-video-file.mp4" type="video/mp4">
</video>


So let's examine this code:

video: This is the HTML5 tag used to embed videos.

width and height: These attributes set the dimensions of the video player on the web page. You can adjust the values according to your needs.
In this example I have set the width to be 100% in order for the video to take the whole available space and didn't specify the height, in order that it's calculated dynamically to keep the video proportions.
If you prefer, you can also set a fixed height and width in pixels for the video.

autoplay: This attribute will make the video to play automatically, which is often required when adding it on a web page

source: This is a child tag of video and is used to specify the video source file. The src attribute should be set to the path of your MP4 video file. The type attribute specifies the MIME type of the video, in this case "video/mp4".



See More HTML ExamplesHire Me For A Project






 
Connect with meLinkedIn ProfileFacebook Profile


2024 © SofiaCoder.com
×

Programming ExamplesPHP ExamplesMySQL ExamplesJavaScript ExamplesHTML ExamplesCSS ExamplesNode.js ExamplesOther Home PageSofia Coder LinkedIn ProfileSofia Coder Facebook Profile