I'm trying to get into adding microformats to my site, but I'm still confused about a couple of things.
Do microformats always have to be within an hcard or vcard element?
Can I have multiple hcards on one page?
Can I have non-microformat content inside an hcard tag?
I'm working on a site and they have their address in two places on their homepage, as well as a callout for a hotline. So I'm just trying to figure out how to place开发者_JS百科 the microformats.
Assuming everything has to be wrapped in an hcard element, would this be the correct way to mark up my code for the hotline callout?
<p class="hcard">Call us 24 hours a day, 7 days a week at <span class="tel hotline">415.441.KIDS (5437)</span></p>
Is using the class "hotline" ok? Can I put both "tel" and "hotline" in the same class attribute? Is it ok that that extra 24/7 text is inside the hcard element? What about the letters/numbers part at the end?
- No.
- Yes.
- Yes.
Your example should look like this:
<p class="vcard">Call us 24 hours a day, 7 days a week at <span class="tel hotline"><abbr title="415.441.5437" class="value">415.441.KIDS (5437)</abbr></span></p>
Changes:
- The root class is vcard, not hcard.
- The "tel" needs a value. (It can also have a "type", which defaults to "voice".)
- Use
<abbr>
to indicate the machine-readable value. ("415.441.KIDS (5437)" isn't quite a phone number; it's a description of a phone number.)
Is using the class "hotline" ok?
Yes.
Can I put both "tel" and "hotline" in the same class attribute?
Yes.
Is it ok that that extra 24/7 text is inside the hcard element?
Yes.
What about the letters/numbers part at the end?
No (see above).
I think you are confused. hcard is one specific microformat (among others):
hCard is a simple, open, distributed format for representing people, companies, organizations, and places, using a 1:1 representation of vCard (RFC2426) properties and values in semantic HTML or XHTML. hCard is one of several open microformat standards suitable for embedding in HTML, XHTML, Atom, RSS, and arbitrary XML.
Therefore you can have many hcards in a page, each representing one people, company, etc. E.g. in your company's site, one for each office or for people in the organisation
精彩评论