怎么在html插入视频
时间: 2024-05-18 09:18:14 浏览: 399
在HTML中插入视频有多种方式,以下是其中两种比较常用的方法:
1. 使用 `<video>` 标签
可以使用 `<video>` 标签来插入视频,示例如下:
```
<video width="320" height="240" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
```
其中,`src` 属性指定视频文件的地址,`type` 属性指定视频文件的 MIME 类型,`controls` 属性表示显示视频播放控制栏。如果浏览器不支持 `<video>` 标签,则会显示 `Your browser does not support the video tag.`。
2. 使用 `<iframe>` 标签
可以使用 `<iframe>` 标签来插入一个包含视频的网页,示例如下:
```
<iframe width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID" frameborder="0" allowfullscreen></iframe>
```
其中,`src` 属性指定视频网页的地址,`width` 和 `height` 属性指定视频的宽度和高度,`allowfullscreen` 属性表示允许全屏播放。需要将 `VIDEO_ID` 替换成 YouTube 视频的 ID。
以上是两种比较常用的方法,还有其他方式,可以根据具体情况选择使用。
阅读全文
相关推荐











