HTML 图像链接语法中的某些内容对我来说没有意义
<A HREF="http://www.computerhope.com"> <IMG SRC="http://www.computerhope.com/logo.gif"> </a>
这是如何链接图像的正确语法。
两个问题:
“>”的作用是什么? href值关闭后?显然,最后的“< A”被“/a”关闭。好像多了一个结束符“>”在这里,但这是正确的语法。
为什么
是用“
>
”关闭的,而不是“/>
”或“< ;/IMG
"?
谢谢。
<A HREF="http://www.computerhope.com"> <IMG SRC="http://www.computerhope.com/logo.gif"> </a>
This is a propere syntax of how to link an image.
Two questions:
What does the ">" after the href value closes? Obviously the "< A" is being closed by the "/a" at the very end. It seems like there's an extra closing ">" here, but that is the right syntax.
Why is the
<IMG>
closed by ">
" and not "/>
" or "</IMG
"?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这表明当前标签的结束。 (即锚点开始标记的结尾)
锚点具有开始标记(
+ 属性)和结束标记(
)。
图像元素被定义为 EMPTY(即它不能包含任何内容),因此结束标记是(在 HTML 4 中) )不必要的、毫无意义的,因此被禁止。
因为它不是 XHTML。 XHTML 基于 XML 而不是 SGML,并且不能有可选或禁止的标签。结束标记必须显式包含在 XHTML 中(或者必须使用自闭合语法 (
) 将整个元素表示为单个标记)。That indicates the end of the current tag. (i.e. the end of the anchor start tag)
The anchor has a start tag (
<a>
+ attributes) and an end tag (</a>
).The image element is defined as EMPTY (i.e. it cannot contain anything) so the end tag is (in HTML 4) unnecessary, pointless and thus forbidden.
Because it is not XHTML. XHTML is based on XML rather then SGML and can't have optional or forbidden tags. The end tag must be included explicitly in XHTML (or self-closing syntax must be used (
<foo />
) to represent the entire element as a single tag).包含内容的 HTML 元素始终具有开始标记
和结束标记。中间有内容。就像 XML 一样。否则就无法区分什么是属性,什么是内容。
不确定您引用的是哪个元素,但如果它是
IMG
:没有内容的元素,则不需要结束标记(与 XML 不同,您可以将其写为 self-结束标签)
。 -3.2英寸rel="nofollow">查看 HTML 4 规范:
HTML elements with content always have a start tag
<tag>
and an end tag</end>
. In between there is the content. Just like XML. Otherwise there would be no way to tell, what is an attribute and what is the content.Not sure to which element you refer, but if it is
IMG
: elements without content, don't need an end tag (unlike in XML, where you would write this as self-closing tag<img ... />
).Have a look at the HTML 4 specification:
a 标记是锚标记,因此它需要在开始标记和结束标记之间作为锚文本或在本例中为图像。
锚标记的语法是
无论您在...所在的位置放置什么,都是链接的锚点,可以是文本或图像。
有些标签没有像 a 标签那样的开始和结束标签。
图像标签只需以 /> 结束即可或>取决于您正在编写的 html 版本。
The a tag is an anchor tag so it needs something between the opening and closing tag to be the anchor text or in this case image.
Syntax for the anchor tag is
What ever you put where the ... is, is the anchor for the link being either text or image.
Some tags doen't have an opening and closing tag like the a tag.
Image tags simply close with the /> or > depending on which version of html you are writing.