This article is currently in the process of being translated into Chinese (~96% done).
If you are fluent in Chinese, then please help us - just point to any untranslated element (highlighted with a yellow left border - remember that images should have their titles translated as well!) inside the article and click the translation button to get started. Or have a look at the current translation status for the Chinese language.
If you see a translation that you think looks wrong, then please consult the original article to make sure and then use the vote button to let us know about it.
Metadata
Please help us by translating the following metadata for the article/chapter, if they are not already translated.
If you are not satisfied with the translation of a specific metadata item, you may vote it down - when it reaches a certain negative threshold, it will be removed.
Please only submit an altered translation of a metadata item if you have good reasons to do so!
Please login to translate metadata!
Already logged in? Please try reloading the page!
如你所见,这个链接元素由起始标签<a>和结束标签</a>组成。链接元素的内容是"This is a link"。但是在起始标签中有一个属性href。这个href-属性永远有一个值,在这个例子中这个值是http://www.myurl.com。每当你想给一个元素赋予一个属性,写属性的方式就为:attribute(属性)="value"(值)。
这里你需要注意一点,属性的名字后面跟着一个等号=,然后这个属性的值永远被双引号“”包裹。在HTML5中你其实可以省略双引号,前提是这个值不包含限制性的符号(比如>, =, or a space),但是这样做会增加错误的风险——让我们看一个图片元素来举个例子。
<img src="my-puppy.jpg" alt="This is a picture of my puppy, Bob">
如果你看这个alt-属性(alt是abbreviation of alternate text的缩写),其中有几个单词。如果你用双引号就没什么问题——双引号表示在其中的每个东西都是alt-属性的值。但是因为空格是一个限制性符号, 你就不能这么写:
<img src="my-puppy.jpg" alt=This is a picture of my puppy, Bob>
如果你这么写了,浏览器就会认为你的alt-属性只有“this”这么一个值。然后剩下的("a picture of my puppy, Bob")本来应该是alt-属性的值就可能将其余的页面打乱。
你学到的:
一些HTML元素可以有属性
写属性的方式就为:attribute(属性)="value"(值)
属性为元素提供附加的信息
属性永远包含在开始标签中
你不一定非要使用双引号,但使用它是一个非常好的主意。
希望你现在理解了基本的HTML,这样的话我们就可以向你的第一个网页进发了,在下一章节。
This article has been fully translated into the following languages: