图像标签关闭 [英] Image tag closing
问题描述
如何关闭HTML中的图片标签?
< img src =#>< / img>
或
< img src =#/>
或
< img src =#>
按照以下HTML5标准: http://www.w3.org/TR/html-markup/syntax.html#
$ b
开始标记包含以下部分,正如以下
>
顺序:
- <
- 元素的标签名称。
- 可选地,一个或多个属性,每个属性前面必须有一个或多个空格字符。 / li>
- 可选地,包含一个或多个空格字符。
- 也可以是/字符,只有元素为空元素时才可以存在。
- 一个>字符。
code> img 是一个 void 元素,因此第5部分将适用于 a'/'字符的警告,
=.../>所以,您 可能 省略第5部分即关闭/,因此这也是有效的:
< img id =... src =...>
更进一步的规格说:
Void元素只有一个开始标签;对于void元素,不得指定结束标签
。
所以,不需要结束标签。
How to close image tag in HTML?
<img src="#"></img>
or
<img src="#" />
or
<img src="#">
As per this HTML5 standard: http://www.w3.org/TR/html-markup/syntax.html#void-element
Start tags consist of the following parts, in exactly the following order:
- A "<" character.
- The element’s tag name.
- Optionally, one or more attributes, each of which must be preceded by one or more space characters.
- Optionally, one or more space characters.
- Optionally, a "/" character, which may be present only if the element is a void element.
- A ">" character.
The img
is a void element and hence the part #5 would apply with a caveat that "a '/' character, which may be present..."
<img id="..." src="..." />
And so, you may omit the part #5 i.e. the closing "/", and hence this is also valid:
<img id="..." src="..." >
Further down the spec says:
Void elements only have a start tag; end tags must not be specified for void elements.
So, no end tag is required.
这篇关于图像标签关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!