Skip to main content
Practice

HTML video Tag

The <video> tag allows you to display videos on a webpage.

The HTML video tag uses the src attribute to specify the path of the video file.

The video file path can refer to a location of a local (same computer) file or a URL on the internet.

Inside the <video> tag, you can include alternative content that gets displayed if the video is not supported.

For example, you can specify the path of a video file using HTML code like this:

Local Video File
<video src="/src/birthday.mp4">Birthday</video>

URL Video
<video src="https://www.my-drive.com/birthday.mp4">Birthday</video>

To display a video URL such as http://media.w3.org/2010/05/sintel/trailer.mp4 on a website, you can write HTML like this:

Adding a Video
<video src="http://media.w3.org/2010/05/sintel/trailer.mp4">Test Video</video>

However, using the video tag in this way will not allow you to play or pause the video.

To add playback controls, you need to add the controls attribute to the video tag.

These controls include buttons for play/pause, volume adjustment, and a slider to control the video's progress.

Adding Video Controls
<video src="http://media.w3.org/2010/05/sintel/trailer.mp4" controls>
Test Video
</video>

By adding the "controls" attribute to the video tag, you will be able to play and pause the video.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.