[uf-discuss] Can singular sub-properties be mixed with parent property?

Tantek Ç elik tantek at cs.stanford.edu
Thu Oct 27 16:57:37 PDT 2005


On 10/27/05 3:53 PM, "Scott Reynen" <scott at randomchaos.com> wrote:

> I just added hCard formatting to the contact info on my personal
> website, 

Awesome!  

Make sure to add the page with your hCard to the "Examples in the Wild"
section in the spec:

 http://microformats.org/wiki/hcard#Examples_in_the_wild

> and I came across some uncertainty about handling of
> singular sub-properties.
> 
> My two actual cases were, class="org organization-name" and
> class="tel value", both of which appear to be redundant on further
> reading.  But is this kind of mixing of sub-properties with parent
> properties in the same class list generally proper syntax for cases
> where only one sub-property is used?

This is a great question Scott, and I think one that many others will have
so I will add it to the FAQ.

The short answer is no.  For *lots* of reasons (including disambiguation
from the parent's subproperties), all sub-properties MUST be on elements
*inside* the property.

(many many months ago, maybe a year ago?, Brian Suda and I thought about
this possibility and tried to make it work with X2V etc., but quickly
realized that we would numerous problematic cases, so in this instance, in
order to make the data parsable, we ask just a *a little bit* of the
content, that is, a separate element for a sub-property from the element for
a property)

On to your specific examples:


> If, for example, I wanted to
> indicate that I work in the espionage department, but not specify
> which company I work for, would the following be okay?
> 
> <span class="org organization-unit"> Espionage </a>

No, but for several reasons.  Both the above reason, and:

If you want to explicitly *not* specify the which company name (which, I
should point out, is NOT the common case, and certainly NOT the 80/20, so
bear with me on the markup), you should add that:

<span class="organization-name"></span>

This is essentially the equivalent of the symbol "0" for numbers.

Thus:

<span class="org">
 <span class="organization-name"></span>
 <span class="organization-unit">Espionage</span>
</span>


> Or if I only wanted to list my last name?
> 
> <span class="n family-name">Smith</span>

Adding "fn", since that is required as part of hCard/vCard, and following
the pattern in the previous example:

<span class="n fn">
 <span class="given-name"></span>
 <span class="n family-name">Smith</span>
</span>


> And while I'm at it, what if two sub-properties have the same value?
> If one's name were "Rose Rose," could I do the following?
> 
> <span class="n given-name family-name">Rose</span>

Almost!

In general you can do this:

<span class="n"><span class="given-name family-name">Rose</span></span>

In particular for hCard, since "fn" is required, and the fn is "Rose Rose"
as you said, you have split them up:

<span class="fn n">
 <span class="given-name">Rose</span>
 <span class="family-name">Rose</span>
</span>


> On another note, I didn't previously mention any type on my address,
> but it was imported as a business address for some reason, so I
> wanted to specify the type as home.  I don't see any way to do this
> without adding information to my content, .e.g <span
> class="type">Home</span>, which is what I did.  It's not a big deal
> for me, but this is the first time I've needed to change the content
> of a page in order to add a microformat, and I thought it might be
> worth mentioning.

This is by design.  The point is that the fact that it is a "home" address
is (meta)data, and in general, it's been well demonstrated that invisible
metadata fails (especially when it scales, c.f. meta keywords).

By making you make the decision about "is this information important enough
that I publish it", it means that you think about the accuracy of the
information, much more so than if you were to just throw something into an
invisible field somewhere.

And especially if and *when* the information changes, you, or anyone else
familiar with you, your web page, and the specific information will *notice*
the inconsistency, because it is *visible*, and point it out to you, and
through this feedback loop, the accuracy has a much better chance of being
maintained/improved.

Also note that you can use abbreviations as many people do for phone
numbers, e.g.:

<span class="tel">
 <abbr class="type" title="home">h:</abbr>
 <span class="value">+1.415.555.1212</span>
</span>

Which could be styled/presented as:

h: +1.415.555.1212

Hope that helps!

Thanks,

Tantek



More information about the microformats-discuss mailing list