HTML 图像链接语法中的某些内容对我来说没有意义

发布于 2024-11-16 09:02:51 字数 402 浏览 0 评论 0原文

<A HREF="http://www.computerhope.com"> <IMG SRC="http://www.computerhope.com/logo.gif"> </a>

这是如何链接图像的正确语法。

两个问题:

  1. “>”的作用是什么? href值关闭后?显然,最后的“< A”被“/a”关闭。好像多了一个结束符“>”在这里,但这是正确的语法。

  2. 为什么是用“>”关闭的,而不是“/>”或“< ;/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:

  1. 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.

  2. Why is the <IMG> closed by ">" and not "/>" or "</IMG"?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

水波映月 2024-11-23 09:02:51

“>”是什么意思href值关闭后?

这表明当前标签的结束。 (即锚点开始标记的结尾)

显然,最后的“< A”被“/a”关闭。好像多了一个结束符“>”在这里,但这是正确的语法。

锚点具有开始标记( + 属性)和结束标记()。

为什么被“>”关闭

图像元素被定义为 EMPTY(即它不能包含任何内容),因此结束标记是(在 HTML 4 中) )不必要的、毫无意义的,因此被禁止。

而不是“/>”或“”?


因为它不是 XHTML。 XHTML 基于 XML 而不是 SGML,并且不能有可选或禁止的标签。结束标记必须显式包含在 XHTML 中(或者必须使用自闭合语法 () 将整个元素表示为单个标记)。

What does the ">" after the href value closes?

That indicates the end of the current tag. (i.e. the end of the anchor start tag)

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.

The anchor has a start tag (<a> + attributes) and an end tag (</a>).

Why is the <IMG> closed by ">"

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.

and not "/>" or "</IMG"?

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).

梦萦几度 2024-11-23 09:02:51

“>”是什么意思href值关闭后?

包含内容的 HTML 元素始终具有开始标记 和结束标记 。中间有内容。就像 XML 一样。否则就无法区分什么是属性,什么是内容。

为什么用“>”结束而不是“/>”或“

不确定您引用的是哪个元素,但如果它是 IMG:没有内容的元素,则不需要结束标记(与 XML 不同,您可以将其写为 self-结束标签

。 -3.2英寸rel="nofollow">查看 HTML 4 规范:

每个元素类型声明通常描述三个部分:开始标记、内容和结束标记。

元素的名称出现在开始标记(写作 )和结束标记(写作 )中;请注意结束标记中元素名称之前的斜杠。例如,UL 元素类型的开始和结束标记分隔列表中的项目:

<前><代码>

  • ...列表项 1...

  • ...列表项 2...

某些 HTML 元素类型允许作者省略结束标记(例如,PLI 元素类型)。一些元素类型还允许省略开始标签;例如,HEADBODY。 HTML DTD 指示每种元素类型是否需要开始标记和结束标记。

What does the ">" after the href value closes?

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.

Why is the closed by ">" and not "/>" or "

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:

Each element type declaration generally describes three parts: a start tag, content, and an end tag.

The element's name appears in the start tag (written <element-name>) and the end tag (written </element-name>); note the slash before the element name in the end tag. For example, the start and end tags of the UL element type delimit the items in a list:

<UL>
<LI><P>...list item 1...
<LI><P>...list item 2...
</UL>

Some HTML element types allow authors to omit end tags (e.g., the P and LI element types). A few element types also allow the start tags to be omitted; for example, HEAD and BODY. The HTML DTD indicates for each element type whether the start tag and end tag are required.

失与倦" 2024-11-23 09:02:51

a 标记是锚标记,因此它需要在开始标记和结束标记之间作为锚文本或在本例中为图像。

锚标记的语法是

<a href="url/link">....</a>

无论您在...所在的位置放置什么,都是链接的锚点,可以是文本或图像。

有些标签没有像 a 标签那样的开始和结束标签。

<a href=""></a>

图像标签只需以 /> 结束即可或>取决于您正在编写的 html 版本。

<img src="" >

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

<a href="url/link">....</a>

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.

<a href=""></a>

Image tags simply close with the /> or > depending on which version of html you are writing.

<img src="" >
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文