首页  >  文章  >  web前端  >  在 HTML 中嵌入标签

在 HTML 中嵌入标签

WBOY
WBOY原创
2024-09-04 16:32:27709浏览

HTML 中的嵌入标签的目的是用于显示外部资源或应用程序。这主要用于多媒体内容,例如将视频文件或音频文件显示到我们的 HTML 应用程序中。此标签还用于导入 Flash 动画师等插件。该标签是在 HTML 5 版本中引入的。它确实有结束标签,如

、、

等。等等

实时示例:我们已经看到很多网站在这些网站中包含媒体文件。不支持普通标签显示媒体文件。因此,我们在 HTML 中为所有类型的媒体文件使用了嵌入标签。

注意:此标签还用于包含图像和外部 html 文件。

嵌入标签在 Html 中如何工作?

HTML 嵌入工作基于 4 个属性。这些属性指定嵌入必须执行的操作。

语法:

<embed Required attributes>

必需属性:标签允许任何 HTML 文档中的属性。

1。 height: 这些属性用于指定嵌入内容元素的高度。该值以像素为单位。

语法:

<embed height="value in pixels">

2。 width: 这些属性用于指定嵌入内容元素的宽度。该值以像素为单位。

语法:

<embed width="value in pixels">

3。 src: 用于携带网址,即用于指定嵌入内容的网址。

语法:

<embed src="web URL">

4。 type: 此属性用于指定媒体类型,如视频或音频。

语法:

<embed type="type of media">

在 HTML 中嵌入标签的示例

以下是下面提到的示例:

示例 #1 – 嵌入图像

代码:

<!DOCTYPE html>
<html>
<title>embed attribute</title>
<head>
<!-- CSS Code -->
<style>
p {
color: red;
border: 2px solid green;
font-size: 22px;
}
h1 {
color: orange;
text-align: center;
}
</style>
</head>
<body>
<h1>The embed tag introduction</h1>
<p>
The
<embed>
tag in HTML purpose is for displaying external resources or
applications. This is used mostly in multimedia content like showing
video files or audio files into out HTML application. This embed tag
is also used for importing plug-ins like flash animators. This embed
tag is introduced in HTML 5 version. It does have ending tag as like p
tag, <html>, <body>, <a> etc.
</p>
<p>Real Time Example: We have seen so many website contains media
files within that websites. Normal tag are not supported to display
media files. So we have used embed tag for all types of media files in
HTML.</p>
<h1>The embed tag Example</h1>
<embed src="d6.jpg" width="400" height="400">
</body>
</html>

输出:

在 HTML 中嵌入标签

示例 #2 – 嵌入其他 html 资源

HTML 代码:EmbedResource.html

<!DOCTYPE html>
<html>
<title>embed attribute</title>
<body>
<!-- Embed content from other html file -->
<embed src="Resource.html" width="1000" height="200">
</body>
</html>

HTML 代码:Resource.html

<!DOCTYPE html>
<html>
<title>embed attribute</title>
<head>
<!-- CSS Code -->
<style>
p {
color: brown;
border: 2px ridge navy;
font-size: 22px;
}
h1 {
color: blue;
text-align: center;
}
</style>
</head>
<body>
<h1>The embed tag introduction</h1>
<p>
The
<embed>
tag in HTML purpose is for displaying external resources or
applications. This is used mostly in multimedia content like showing
video files or audio files into out HTML application. This embed tag
is also used for importing plug-ins like flash animators. This embed
tag is introduced in HTML 5 version. It does have ending tag as like p
tag, <html>, <body>, <a> etc.
</p>
<p>Real Time Example: We have seen so many website contains media
files within that websites. Normal tag are not supported to display
media files. So we have used embed tag for all types of media files in
HTML.</p>
</body>
</html>

输出:

在 HTML 中嵌入标签

在 HTML 中嵌入标签

示例 #3 – 嵌入视频文件

代码:

<!DOCTYPE html>
<html>
<title>embed attribute</title>
<head>
<!-- CSS Code -->
<style>
p {
color: brown;
border: 2px ridge navy;
font-size: 22px;
}
h1 {
color: blue;
text-align: center;
}
</style>
</head>
<body>
<h1>The embed tag introduction</h1>
<p>
The
<embed>
tag in HTML purpose is for displaying external resources or
applications. This is used mostly in multimedia content like showing
video files or audio files into out HTML application. This embed tag
is also used for importing plug-ins like flash animators. This embed
tag is introduced in HTML 5 version. It does have ending tag as like p
tag, <html>, <body>, <a> etc.
</p>
<p>Real Time Example: We have seen so many website contains media
files within that websites. Normal tag are not supported to display
media files. So we have used embed tag for all types of media files in
HTML.</p>
<!-- Embed content from other video file -->
<embed src="nationalgeography.mp4" width="400" height="300">
</body>
</html>

输出:

在 HTML 中嵌入标签

在 HTML 中嵌入标签

结论

嵌入 HTML 用于将视频和音频文件包含到我们的 HTML 应用程序中。可以使用高度和宽度属性根据我们的要求调整此外部嵌入资源的大小。

以上是在 HTML 中嵌入标签的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
上一篇:tfoot in HTML下一篇:href tag in HTML