video Tag
The video tag creates an area on your web page for video playback.
For example, you can embed a video in a web page as shown below:
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4" />
Your browser does not support the video tag.
</video>
-
width
andheight
: Specify the dimensions of the video player -
controls
: Display video controls such as play/pause buttons -
<source>
: Specify the path and type of the video file
Considerations When Using the <video>
Tag
-
File Format
: Not all video file formats are supported by every browser. Therefore, it's a good practice to prepare multiple video file formats to ensure compatibility. -
Alternative Text
: The text inside the video tag provides fallback content for browsers that do not support the video element. It's helpful to describe the video content here. -
Data Usage
: Video files can be large, which may affect page loading times. Use videos only when necessary and compress files to keep their size manageable.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.