Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html for Snail Mail Addresses

What do you think is the best way to markup a snail mail address? I found some different options such as:

<div class="address">
<span class="name">Mr. Bob</span><br/>
<span class="street">45654 Bob Ln</span><br/>
<span class="city">Imaginery</span>,<span class="state">OH</span><br/>
<span class="postalCode">44321</span>
</div>

I also saw the previous example using an address tag instead of a div. Another option I found was:

<div class="address">
  <p>Mr. Bob</p>
  <p>45654 Bob Ln</p>
  <p>Imaginery, OH</p>
  <p>44321</p>
</div> 

So my question is what do you think is the best markup to express a snail mail address? And do not limit yourself to my examples.

I feel the first one is the best option, as it provides additional context about each element. I also feel the br is part of the content in this case.

like image 606
JoshBerke Avatar asked Apr 08 '09 14:04

JoshBerke


3 Answers

Use the adr microformat:

http://microformats.org/wiki/adr

If you also want to mark up the persons name use hCard:

http://microformats.org/wiki/hcard

Which includes adr.

like image 128
singpolyma Avatar answered Nov 10 '22 11:11

singpolyma


How about the <address> tag?

Edit:

It appears the commentors are correct, this tag is generally used to represent contact information from the authors of a page or form.

From the HTML 4.1 Specification...

The ADDRESS element may be used by authors to supply contact information for a document or a major part of a document such as a form. This element often appears at the beginning or end of a document.

So, if it's your address you're displaying, use this. Otherwise, use what singpolyma suggested.

like image 37
John Rasch Avatar answered Nov 10 '22 12:11

John Rasch


Using <br>s is definitely more correct than <p>s; for the class names I follow singpolyma.

like image 3
Ms2ger Avatar answered Nov 10 '22 12:11

Ms2ger