Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Correct usage of HTML5 <address> element?

Tags:

html

I'm searching for correct usage of <address> element.

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?

like image 904
Canser Yanbakan Avatar asked Nov 20 '14 14:11

Canser Yanbakan


People also ask

What is the work of address element in html5?

The <address> HTML element indicates that the enclosed HTML provides contact information for a person or people, or for an organization.

What is the correct way to write address in an HTML document?

The <address> tag in HTML is used to write contact information of a person or an organization. If <address> tag is used inside the <body> tag then it represents the contact information of the document and if the <address> tag is used inside the <article> tag, then it represents the contact information of the article.

What is the correct element for HTML?

The <html> element is the root element and it defines the whole HTML document. It has a start tag <html> and an end tag </html> .

Is HTML 5 an address tag?

HTML 5 <address> Tag If the tag applies to the body element, then it applies to the document as a whole. The <address> tag must not be used to represent arbitrary addresses (e.g. postal addresses), unless those addresses are contact information for the section. To display postal addresses, simply use the <p> tag.


2 Answers

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 (e.g. 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.)

Ref, Living standard: 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

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. Regarding address, it represents contact information for its nearest article or body and is also allowed in footer.

like image 91
Abhitalks Avatar answered Oct 06 '22 01:10

Abhitalks


Well, depending on this source the <address> tag is not an actually address in your usecase. Its more like a pointer to the page author. Means, it should contain your own address.

Additional info by w3schools

  • The <address> tag defines the contact information for the author/owner of a document or an article.

  • If the <address> element is inside the <body> element, it represents contact information for the document.

  • If the <address> element is inside an <article> element, it represents contact information for that article.

like image 22
Der Vampyr Avatar answered Oct 05 '22 23:10

Der Vampyr