写一个<address>的正确方法标记我的网站,以提供我们公司的联系方式 [英] Correct way for writing an <address> tag for my web site, to provide Contact details for our company

查看:23
本文介绍了写一个<address>的正确方法标记我的网站,以提供我们公司的联系方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net mvc-5建立一个网站,我想提供我们公司的联系方式,例如电话、电子邮件、邮政地址等.所以我使用了

在我们的联系我们"页面中标记如下(我用 *** 替换了真实数据):-

<div class="col-lg-4 col-md-4 col-sm-4 地址"><h2>地址</h2><地址><div class="信息"><p><span class="footercolor">电话:</span><span>+******</span></p><p><span class="footercolor">传真:</span><span class="marginfax">+*****</span></p><p class="mainaddress">3楼,Bldg.1(....),<br/>... Str..CityName

<p><span class="footercolor">P</span>.<span class="footercolor">O</span>.<span class="footercolor">框:</span>*****,**** 1212,CountryName

<p><span class="footercolor">电子邮件:</span><span><a href="mailto:info@****.com " target="_top">info@*****.com</a></span></p>

</地址>

所以我有几个关于使用

标签的问题:-

  • 在这个链接中,他们提到了以下关于地址标签的内容提示:

    标签不应用于描述邮政地址,除非它是联系信息的一部分....所以我为什么不添加
    标签内的邮政地址?

  • 标签是否像我目前所做的那样是提供我们公司联系方式的正确方式,或者它应该用于提供有关网站所有者的详细信息,例如谁创建了网站以及何时....

  • 与在基本的

    标签内提供联系信息相比,在
    标签内提供联系信息有什么优势?代码>

    ?

解决方案

何时应该使用地址标签

来自 W3C (https://www.w3.org/TR/html-markup/address.html):

<块引用>

如果一个地址元素适用于一个正文元素,那么它代表整个文档的联系信息.如果一个地址元素适用于文档的一部分,那么它代表联系仅适用于该部分的信息.

总而言之,地址标签用于联系信息.如果您的联系信息只是一个电话号码,那么地址块中应该只包含电话号码.如果您的联系信息是电话号码、邮政地址和电子邮件,那么所有这些信息(包括邮政地址)都应包含在地址块中.

什么时候不应该使用地址标签

关键是,如果不是联系信息,则不应在地址块中包含邮政地址.因此,例如,如果您有一个房地产网站,并且您要列出有关可用房屋的信息,则房屋清单的地址不应位于地址块中.另一方面,房地产经纪人的地址应包含在地址块中,因为这是联系信息.

为什么要使用地址标签

HTML 是语义化的.即/您提供内容并赋予该内容以意义.您可以赋予内容的意义越多,效果就越好.地址传达的含义远不止 div 或 p,所以如果地址合适,您应该使用地址.事实上,这就是 W3C 关于 div 的说法(https://www.w3.org/TR/html5/grouping-content.html#the-div-element):

<块引用>

强烈鼓励作者将 div 元素视为一个元素万不得已,因为当没有其他元素适合时.使用更多适当的元素而不是 div 元素导致更好读者可访问,作者更易于维护.

地址标签中可接受的内容

地址块内的 Divs 和 Ps 是完全可以接受的.更具体地说,这是您可以在地址块中使用的内容(来自 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address):

<块引用>

流内容,但没有嵌套的

元素,没有标题内容(<hgroup>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>),没有分节内容(<article>,<aside>,<section>,<nav>),并且没有 <header>或<页脚>元素.

Divs 和 Ps 是流内容.

tl;dr:也许你可以让你的代码更漂亮一点.但是关于地址标签的使用,你很好!

I am building a website using asp.net mvc-5, and I want to provide our company contact details such as telephone, email, postal address, etc.., so I used the <address> tag as follow inside our "Contact US" page (I replace the real data by ***):-

<div class="row">
  <div class="col-lg-4 col-md-4 col-sm-4 address">
    <h2>Addresses</h2>
    <address>
      <div class="info">
        <p><span class="footercolor">Telephone: </span><span>+******</span></p>
        <p><span class="footercolor">FAX: </span><span class="marginfax">+*****</span></p>
        <p class="mainaddress">3rd Floor, Bldg. 1(....),<br />... Str. .CityName</p>
        <p><span class="footercolor">P</span>.<span class="footercolor">O</span>.<span class="footercolor">Box: </span><span>*****,**** 1212,CountryName</span></p>
        <p><span class="footercolor">Email:</span><span> <a href="mailto:info@****.com " target="_top">info@*****.com</a></span></p>
      </div>
    </address>
  </div>

so I have a couple of questions about using the <address> tag:-

  • inside this link they mentioned the following about the address tag Tip: The <address> tag should NOT be used to describe a postal address, unless it is a part of the contact information.... so why I should not add the postal address inside the <address> tag?

  • Is the <address> tag the correct way to provide our company's contact details as I am currently doing, or it should be used to provide details about the web site owner such as who created the web site and when ....

  • What are the advantages of providing the contact info inside <address> tag compared to writing the contact info inside a basic <div> or <p>?

解决方案

When you should use an address tag

From the W3C (https://www.w3.org/TR/html-markup/address.html):

If an address element applies to a body element, then it represents contact information for the document as a whole. If an address element applies to a section of a document, then it represents contact information for that section only.

In summary, an address tag is for contact information. If your contact information is just a phone number, then only the phone number should be included in the address block. If your contact information is a phone number(s), postal address, and e-mail as in your case, then all of this information (including the postal address) should be contained within the address block.

When you should NOT use an address tag

The point is, you should not be including a postal address in the address block if it is NOT contact information. So for example, if you have a real estate website, and you're listing information about available houses, the address of a house listing should not be in the address block. On the other hand, the real estate agent's address should be included in the address block, since this is contact information.

Why use the address tag

HTML is meant to be semantic. Ie/ you provide content and give meaning to that content. The more meaning you can give to the content, the better. Address conveys a lot more meaning than just div or p, so if address is appropriate, you should use address. In fact, here's what the W3C says about divs (https://www.w3.org/TR/html5/grouping-content.html#the-div-element):

Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable. Use of more appropriate elements instead of the div element leads to better accessibility for readers and easier maintainability for authors.

Acceptable content within an address tag

Divs and Ps inside an address block are perfectly acceptable. More specifically, here's what you can use within an address block (from https://developer.mozilla.org/en-US/docs/Web/HTML/Element/address):

Flow content, but with no nested <address> element, no heading content (<hgroup>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>), no sectioning content (<article>, <aside>, <section>, <nav>), and no <header> or <footer> element.

Divs and Ps are flow content.

tl;dr: Maybe you could make your code a little prettier. But regarding your usage of the address tag, you're good!

这篇关于写一个&lt;address&gt;的正确方法标记我的网站,以提供我们公司的联系方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆