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

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

问题描述

我正在使用asp.net mvc-5建立一个网站,我想提供我们公司的联系方式,如电话,电子邮件,邮政地址等,所以我使用地址> 标签,如我们的联系我们页面(我用***替换真实数据): -

 < div class =row> 
< div class =col-lg-4 col-md-4 col-sm-4 address>
< h2>地址< / h2>
< address>
< div class =info>
< 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为H.
< p>< span class =footercolor> P< / span>。< span class =footercolor> O< / span>。< span class =footercolor>框:< / span>< span> *****,**** 1212,CountryName< / span>< / p>
< p>< span class =footercolor>电子邮件:< / span>< span> < a href =mailto:info @ ****。comtarget =_ top> info @ *****。com< / a>< / span>< / p>
< / div>
< / address>
< / div>

所以我有几个关于使用< address> / code>标签: -




  • 在这个链接他们提到了关于地址标签的以下内容提示:< address> 标签不应该用于描述邮政地址,除非是联系信息的一部分。 ...所以为什么我不应该将邮政地址添加到< address> 标签?


  • < address> 标签是否提供正确的方法我们公司的联系方式,正如我目前正在做的,或者它应该被用来提供有关网站所有者的详细信息,例如创建网站的时间以及何时.... ....


  • 在基本的< div>内编写联系信息相比,在< address> 标签中提供联系人信息有什么优点? ; < ; p>



解决方案

当您使用地址标签



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



< blockquote>

如果一个地址元素适用于一个body元素,那么它代表
整个文档的联系信息。如果地址元素
适用于文档的一部分,则表示该部分的联系人
信息。




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



不应使用地址标签



重点是,您不应该包含邮政地址在地址块中如果不是联系信息。例如,如果您有房地产网站,并列出有关房屋的信息,则房屋列表的地址不应在地址块中。另一方面,地产代理的地址应该包含在地址块中,因为这是联系信息。



为什么使用地址标签



HTML的意思是语义。也就是说,您提供内容并给予该内容的意义。你可以给内容的意义越大越好。地址传达比div或p更多的意义,所以如果地址是适当的,你应该使用地址。实际上,这里是W3C对于div的说明( https: //www.w3.org/TR/html5/grouping-content.html#the-div-element ):


强烈建议作者将div元素视为最后一个元素
,因为没有其他元素是合适的。使用更多
适当的元素而不是div元素可以为读者提供更好的
可访问性,并为作者提供更容易的维护性。


地址标签内的可接受内容



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


流程内容,但是没有嵌套的< address> 元素,没有标题内容
(< hgroup>,< h1>,< h2& ; h3>,< h4>,< h5>,< h6>),无分割内容
(< article>< aside>< section>,< nav>否< header>或< footer>
元素。


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天全站免登陆