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.
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.
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.
Using <br>
s is definitely more correct than <p>
s; for the class names I follow singpolyma.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With