Html 我应该使用哪个 HTML5 标签来标记作者的姓名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7290504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which HTML5 tag should I use to mark up an author’s name?
提问by Quang Van
For example of a blog-post or article.
例如博客文章或文章。
<article>
<h1>header<h1>
<time>09-02-2011</time>
<author>John</author>
My article....
</article>
The author
tag doesn't exist though... So what is the commonly used HTML5 tag for authors?
Thanks.
author
虽然该标签不存在... 那么作者常用的 HTML5 标签是什么?谢谢。
(If there isn't, shouldn't there be one?)
(如果没有,不应该有一个吗?)
回答by ryanve
Both rel="author"
and <address>
are designed for this exact purpose. Both are supported in HTML5. The spec tells us that rel="author"
can be used on <link>
<a>
, and <area>
elements. Google also recommendsits usage. Combining use of <address>
and rel="author"
seems optimal. HTML5 best affords wrapping <article>
headlines and bylines info in a <header>
like so:
双方rel="author"
并<address>
设计用于此确切目的。HTML5 支持两者。规范告诉我们rel="author"
可以在, 和元素上使用。Google 还推荐了它的用法。结合使用和似乎是最佳的。HTML5 最能提供像这样包装标题和署名信息:<link>
<a>
<area>
<address>
rel="author"
<article>
<header>
<article>
<header>
<h1 class="headline">Headline</h1>
<div class="byline">
<address class="author">By <a rel="author" href="/author/john-doe">John Doe</a></address>
on <time pubdate datetime="2011-08-28" title="August 28th, 2011">8/28/11</time>
</div>
</header>
<div class="article-content">
...
</div>
</article>
The
pubdate
attribute indicates that that is the published date.The
title
attributes are optional flyovers.The byline info can alternatively be wrapped in a
<footer>
within an<article>
If you want to add the hcard microformat, then I would do so like this:
如果你想添加hcard microformat,那么我会这样做:
<article>
<header>
<h1 class="headline">Headline</h1>
<div class="byline vcard">
<address class="author">By <a rel="author" class="url fn n" href="/author/john-doe">John Doe</a></address>
on <time pubdate datetime="2011-08-28" title="August 28th, 2011">on 8/28/11</time>
</div>
</header>
<div class="article-content">
...
</div>
</article>
回答by robertc
HTML5 has an author link type:
HTML5 有一个作者链接类型:
<a href="http://johnsplace.com" rel="author">John</a>
The weakness here is that it needs to be on some sort of link, but if you have that there's a long discussion of alternatives here. If you don't have a link, then just use a class attribute, that's what it's for:
这里的弱点是它需要在某种链接上,但如果你有,这里有一个关于替代方案的长时间讨论。如果您没有链接,则只需使用类属性,这就是它的用途:
<span class="author">John</span>
回答by Jason Gennaro
According to the HTML5 spec, you probably want address
.
根据 HTML5 规范,您可能需要address
.
The address element represents the contact information for its nearest article or body element ancestor.
地址元素表示其最近的文章或正文元素祖先的联系信息。
The spec further references address
in respect to authors here
该规范进一步参考address
了此处的作者
Under 4.4.4
根据 4.4.4
Author information associated with an article element (q.v. the address element) does not apply to nested article elements.
与文章元素(qv 地址元素)相关联的作者信息不适用于嵌套的文章元素。
Under 4.4.9
根据 4.4.9
Contact information for the author or editor of a section belongs in an address element, possibly itself inside a footer.
某个部分的作者或编辑的联系信息属于地址元素,它本身可能位于页脚内。
All of which makes it seems that address
is the best tag for this info.
所有这些都使它看起来address
是此信息的最佳标签。
That said, you could also give your address
a rel
or class
of author
.
也就是说,您也可以给出address
arel
或class
of author
。
<address class="author">Jason Gennaro</address>
Read more: http://dev.w3.org/html5/spec/sections.html#the-address-element
阅读更多:http: //dev.w3.org/html5/spec/sections.html#the-address-element
回答by remyActual
Google support for rel="author" is deprecated:
不推荐使用Google 对 rel="author" 的支持:
"Authorship markup is no longer supported in web search."
“网络搜索不再支持作者标记。”
Use a Description List (Definition List in HTML 4.01) element.
使用描述列表(HTML 4.01 中的定义列表)元素。
From the HTML5 spec:
从HTML5 规范:
The dl element represents an association list consisting of zero or more name-value groups (a description list). A name-value group consists of one or more names (dt elements) followed by one or more values (dd elements), ignoring any nodes other than dt and dd elements. Within a single dl element, there should not be more than one dt element for each name.
Name-value groups may be terms and definitions, metadata topics and values, questions and answers, or any other groups of name-value data.
dl 元素表示由零个或多个名称-值组(描述列表)组成的关联列表。名称-值组由一个或多个名称(dt 元素)后跟一个或多个值(dd 元素)组成,忽略除 dt 和 dd 元素之外的任何节点。在单个 dl 元素中,每个名称不应超过一个 dt 元素。
名称-值组可以是术语和定义、元数据主题和值、问题和答案,或任何其他名称-值数据组。
Authorship and other article meta information fits perfectly into this key:value pair structure:
作者和其他文章元信息完全适合这个键:值对结构:
- who is the author
- date the article published
- site structure under which the article is organized (category/tag: string/arrays)
- etc.
- 谁是作者
- 文章发表日期
- 组织文章的站点结构(类别/标签:字符串/数组)
- 等等。
An opinionated example:
一个固执的例子:
<article>
<header>
<h1>Article Title</h1>
<p class="subtitle">Subtitle</p>
<dl class="dateline">
<dt>Author:</dt>
<dd>Remy Schrader</dd>
<dt>All posts by author:</dt>
<dd><a href="http://www.blog.net/authors/remy-schrader/">Link</a></dd>
<dt>Contact:</dt>
<dd><a mailto="[email protected]"><img src="email-sprite.png"></a></dd>
</dl>
</header>
<section class="content">
<!-- article content goes here -->
</section>
</article>
As you can see when using the <dl>
element for article meta information, we are free to wrap <address>
, <a>
and even <img>
tags in <dt>
and/or <dd>
tags according to the nature of the content and it's intended function.
The <dl>
, <dt>
and <dd>
tags are free to do their job -- semantically -- conveying information about the parent <article>
; <a>
, <img>
and <address>
are similarly free to do their job -- again, semantically -- conveying information regarding where to find related content, non-verbal visual presentation, and contact details for authoritative parties, respectively.
正如您在<dl>
为文章元信息使用元素时所看到的,我们可以根据内容的性质和预期的功能自由包装<address>
,<a>
甚至<img>
标签<dt>
和/或<dd>
标签。
的,并且标签可以自由地做他们的工作-语义-输送更多地了解家长的信息; ,并且同样可以自由地完成他们的工作——同样,在语义上——分别传达有关在哪里可以找到相关内容、非语言视觉呈现和权威方的联系方式的信息。 <dl>
<dt>
<dd>
<article>
<a>
<img>
<address>
回答by HarleySG
In HTML5 we can use some semantic labels that help organize the information regarding your type of content, but additional and related to the subject you can check schema.org. It is an initiative of Google, Bing and Yahoo that aims to help search engines to better understand websites through microdata attributes. Tu post podría tener el siguiente aspecto:
在 HTML5 中,我们可以使用一些语义标签来帮助组织有关您的内容类型的信息,但您可以查看与主题相关的附加信息schema.org。这是谷歌、必应和雅虎的一项倡议,旨在通过微数据属性帮助搜索引擎更好地理解网站。Tu post podría tener el siguiente aspecto:
<article itemscope itemtype="http://schema.org/Article">
<header>
<h1 itemprop="headline">header</h1>
<time itemprop="dateCreated datePublished">09-02-2011</time>
<div itemprop="author publisher" itemscope itemtype="http://schema.org/Organization">
<p>
<img itemprop="image logo" src="..."/>
<span itemprop="name">John</span>
</p>
</div>
</header>
<section itemprop="articleBody" >
My article....
<img itemprop="image" src="..."/>
</section>
</article>
回答by Raphael
You can use
您可以使用
<meta name="author" content="John Doe">
in the header as per the HTML5 specification.
根据HTML5 规范在标头中。
回答by Paul D. Waite
If you were including contact details for the author, then the <address>
tag is appropriate:
如果您包含作者的联系方式,那么<address>
标签是合适的:
But if it's literally just the author's name, there isn't a specific tag for that. HTML doesn't include much related to people.
但如果它实际上只是作者的名字,则没有特定的标签。HTML 没有包含太多与人相关的内容。