본문으로 건너뛰기

<video> Tags in HTML

<video> Tags

To insert videos into web pages, we use the <video> tag.


What is a <video> tag?

The <video> tag creates a space on a web page where videos can be played. This enables you to embed videos into your web pages.

For example, you can embed a video into your web page like this:

How to use video tag
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4" />
This is the alternative text for browsers that do not support the video.
</video>
  • The width and height attributes define the size of the video player.

  • The controls attribute adds video controls like play and pause buttons.

  • The <source> tag specifies the path to the video file and its type.


Key Points for the <video> tag

  1. File Formats: Not all video file formats are supported by every browser. It is a good practice to prepare videos in multiple formats to enhance compatibility.

  2. Alternative Text: The text written between the <source> tags is displayed in browsers that do not support the video tag. Thus, providing a description of the video or an alternative content in this space is beneficial.

  3. Data Usage: Video files can be large and may affect page loading speeds. Use videos judiciously and consider compressing them to reduce their size as much as possible.