简体   繁体   English

正确使用HTML5 <address> 元件?

[英]Correct usage of HTML5 <address> element?

I'm searching for correct usage of <address> element. 我正在寻找<address>元素的正确用法。

For example, i have to show more than one address, so i need to write them in an address element or seperate for each other? 例如,我必须显示多个地址,所以我需要将它们写在地址元素中或彼此分开?

<p>BLA BLA CO.</p>
<address>
    <span class="full-address">XXX ST. XXX ETC.</span>
    <span class="city">IZMIR</span>
    <span class="town">Bornova</span>
    <span class="phone">+11 111 111 1111</span>
    <span class="fax">+11 111 111 1112</span>
</address>

<p>OTHER BLA CO.</p>
<address>
    <span class="full-address">XXX ST. XXX ETC.</span>
    <span class="city">IZMIR</span>
    <span class="town">Bornova</span>
    <span class="phone">+11 111 111 1111</span>
    <span class="fax">+11 111 111 1112</span>
</address>

What is the correct usage of this? 这是什么用法?

In your use-case, it probably is incorrect usage. 在您的用例中,它可能是不正确的用法。

As per the official refs: 根据官方的要求:

The address element must not be used to represent arbitrary addresses (eg postal addresses), unless those addresses are in fact the relevant contact information. 地址元素不得用于表示任意地址(例如邮政地址),除非这些地址实际上是相关的联系信息。 (The p element is the appropriate element for marking up postal addresses in general.) (p元素是用于标记邮政地址的适当元素。)

Ref, Living standard: https://html.spec.whatwg.org/multipage/semantics.html#the-address-element 参考,生活标准: https//html.spec.whatwg.org/multipage/semantics.html#the-address-element

Ref, Spec HTML4.01: http://www.w3.org/TR/html401/struct/global.html#h-7.5.6 参考,规范HTML4.01: http//www.w3.org/TR/html401/struct/global.html#h-7.5.6

Ref, Recomendation HTML5: http://www.w3.org/TR/html5/sections.html#the-address-element Ref,Recomendation HTML5: http//www.w3.org/TR/html5/sections.html#the-address-element

.

You are presenting several postal addresses, and so it seems a p is more appropriate here. 您呈现几个邮政地址,因此它似乎p是比较合适的位置。 Regarding address , it represents contact information for its nearest article or body and is also allowed in footer . 关于address ,它代表最近的articlebody联系信息,也允许在footer

Well, depending on this source the <address> tag is not an actually address in your usecase. 那么,根据这个来源<address>标签不是你用例中的实际地址。 Its more like a pointer to the page author. 它更像是指向页面作者的指针。 Means, it should contain your own address. 意思是,它应该包含你自己的地址。

Additional info by w3schools w3schools的其他信息

  • The <address> tag defines the contact information for the author/owner of a document or an article. <address>标记定义文档或文章的作者/所有者的联系信息。

  • If the <address> element is inside the <body> element, it represents contact information for the document. 如果<address>元素位于<body>元素内,则表示文档的联系信息。

  • If the <address> element is inside an <article> element, it represents contact information for that article. 如果<address>元素位于<article>元素内,则表示该文章的联系信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM