# hCard Microformat (part 3)

### Roger Costello

Click arrow key () to navigate to next page

# label Property

- label - use to specify a delivery address label, such as you might put on a package for mailing.
- This property can include a "type" subproperty, whose values are the same as the type subproperty in adr -- dom (domestic delivery address), parcel, home, work, pref (preferred delivery address).
- Example: markup this HTML text using the hCard properties:

1. <pre>
2. John Q. Smith
3. 10 Boylston St.
4. Boston, MA 01210
5. </pre>

# label Property

- Here is the marked up text:

1. <pre class="vcard">
2. <span class="fn n">
3. <span class="given-name">John</span>
4. <abbr class="additional-name" title="Quinlan">Q.</abbr>
5. <span class="family-name">Smith</span>
6. </span>
7. <span class="label">10 Bolyston St.
8. Boston, MA 01210</span>
9. </pre>

- View example07 (using label).

# label Property

- We can use both the adr and label properties:

1. <div class="vcard">
2. <span class="fn n">
3. <span class="given-name">John</span>
4. <abbr class="additional-name" title="Quinlan">Q.</abbr>
5. <span class="family-name">Smith</span>
6. </span>
7. <br />
8. <span class="adr label">
9. <span class="street-address">10 Bolyston St.</span>
10. <span class="locality">Boston</span>,
11. <abbr class="region" title="Massachusetts">MA</abbr>
12. <span class="postal-code">01210</span>
13. </span>
14. </body>

- View example07 (using label and adr).

# Telecommunication Address Properties

- These properties are used to provide telecommunications addressing information:
  - tel (telephone)
  - email
  - mailer (email software being used)

# tel Property

- tel - use to specify the person's telephone number. The "type" subproperty is used to specify the intended use of the telephone number. Here are the values for the type subproperty:
  - home
  - msg (indicates the telephone number has an answering machine)
  - work
  - pref (indicates that this is the preferred number)
  - voice (indicates that this is a voice number)
  - fax
  - cell
  - video (indicates the number is for a video conferencing system)
  - pager
  - bbs (indicates the number is for a bulletin board system)

# tel Property

- type subproperty values (continued):
  - modem
  - isdn
  - pcs (indicates a personal communication services number)
- If no "type" subproperty is specified it defaults to "voice"
- Example: markup this HTML text:

1. John Q. Smith's home telephone number is: 617-555-1234

# tel Property

- Here is the marked up text:

1. <div class="vcard">
2. <span class="fn n">
3. <span class="given-name">John</span>
4. <abbr class="additional-name" title="Quinlan">Q.</abbr>
5. <span class="family-name">Smith</span></span>'s
6. <span class="tel">
7. <span class="type">home</span>
8. telephone number is:
9. <span class="value">617-555-1234</span>
10. </span>
11. </div>

- Note the use of the "value" property. It ensures that "tel" receives the proper value.
- View example08 (using tel).

# Lab 2

- Markup this HTML using hCard properties:

1. <body>
2. <h1>Robert (Jake) Williams</h1>
3. <h2>VITA</h2>
4. <dl>
5. <dt>Home Address</dt>
6. <dd>1641 Beacon Street</dd>
7. <dd>Philadelphia, Pennsylvania 19123-7774</dd>
8. <dd>215/321-7654</dd>
9. </dl>
10. <dl>
11. <dt>Business Address</dt>
12. <dd>Pennsylvania Commission on Children and Youth</dd>
13. <dd>1436 Market Street</dd>
14. <dd>Philadelphia, Pennsylvania 19125-7707</dd>
15. <dd>215/321-7222</dd>
16. </dl>
17. ... (continued on next slide)

# Lab 2 (cont.)

- Markup this HTML using hCard properties:

1. ...
2. <dl>
3. <dt>Reference</dt>
4. <dd>Dr. Marie D. Fredericks</dd>
5. <dd>Dean, College Of Education Temple University</dd>
6. <dd>Philadelphia, Pennsylvania 19125-0021</dd>
7. <dd>215/321-7111</dd>
8. </dl>
9. </body>

- Here is the HTML document: Vita-Robert-Williams.html
- Hints: (1) there can be multiple occurrences of the "adr" property, (2) an HTML document may contain multiple hCards

# Lab 2 (cont.)

- Name the new version of the HTML file: Vita-Robert-Williams-revised.html
- After marking up the HTML with the hCard properties:
  1. Validate your HTML using the W3C HTML validator: http://validator.w3.org/
  2. Use Brian Suda's xhtml2vcard.xsl tool to extract the hCard and generate a vCard (.vcf file). In the lab 2 folder is run.bat. Double click on it, and it will invoke Brian's tool.

# hCard and Microsoft Outlook

- If you use Outlook for email then you can automatically create contacts from documents that contain hCards.
- Suppose an HTML document contains an hCard of a person. You can generate a vCard from the document by using Brian Suda's xhtml2vcard.xsl tool.
- Then you can install the vCard as a contact in Outlook by following these steps:
  - Open Outlook
  - Click on the Contacts button
  - Under File select Import and Export then select: Import a VCARD file (.vcf)

# Lab 3

- Add Stephen Hawking to your Outlook contacts (import the .vcf file from Lab 1).
- Add Robert Williams and Marie Fredericks to your Outlook contacts (import the .vcf file from Lab 2).

# email Property

- email - use to specify the email address of a person
- A "type" subproperty can be used to specify the format or preference of the email address:
  - internet (indicates it is an internet email address)
  - x400 (indicates it is an X.400 address)
  - pref (indicates the preferred email address when more than one is specified)
- Example: markup this HTML text:

1. His email address is: jpublic@gmail.com

# email Property

- Here is the marked up text:

1. <div class="vcard">
2. <abbr class="fn" title="John Q. Smith">His</abbr>
3. email address is:
4. <a class="email" href="mailto:jpublic@gmail.com">jpublic@gmail.com</a>
5. </div>

- Note: wrap an email address in an HTML anchor (<a>) tag.
- The value of the email property is the value of the href attribute, omitting the "mailto:" prefix and any "?..." query suffix (if present).
- View example09 (using email).

# mailer Property

- mailer - use to specify the type of email software that is used by the person.
- Example: markup this HTML text:

1. The emailing software that he uses is: Microsoft Outlook

- Here is the marked up text:

1. The emailing software that
2. <div class="vcard">
3. <abbr class="fn" title="John Q. Smith">he</abbr>
4. uses is:
5. <span class="mailer">Microsoft Outlook</span>
6. </div>

# Geographical Properties

- These properties are used to provide geographical position information:
  - tz (time zone)
  - geo (lat, lon)

# tz Property

- tz - use to specify the time zone where the person resides.
- Example: markup this HTML text:

1. He lives in the EST time zone.

- Here is the marked up text:

1. He lives in the
2. <abbr class="tz" title="-05:00">EST</abbr>
3. time zone

- Note: use a utc-offset to specify the time zone.

# geo Property

- geo - use to specify the global position of the person. It has two subproperties - latitude and longitude.
- latitude: use a positive number to specify a location north of the equator; use a negative number to specify a location south of the equator.
- longitude: use a negative number to specify a location west of the prime meridian; use a positive number to specify a location east of the prime meridian.
- The latitude and longitude values must be specified as a decimal value, and should be specified to six decimal places. This will allow for granularity to within a meter of the geographical position.

# geo Property

- Example: markup this HTML text:

1. His home GPS location is: 41.537063, -90.561585 (lat/lon)

- Here is the marked up text:

1. His home GPS location is:
2. <div class="geo">
3. <span class="latitude">41.537063</span>,
4. <span class="longitude">-90.561585</span>
5. </div>
6. (lat/lon)

# geo Property

- Typically the creator of HTML text has no interest in displaying lat/lon decimal values on the browser screen. He just wants to display human-oriented text, e.g.,

1. His home is a big, brown house.

- But he does want to make lat/lon geo info available to aggregators (Web tools).
- The HTML text can be extended (without impact to what is seen on the browser screen) to incorporate the geo location information
- Here is the marked up text:

1. <abbr class="geo" title="41.537063;-90.561585">His home</abbr> is a big, brown house.

# geo Property

1. <abbr class="geo" title="41.537063;-90.561585">His home</abbr> is a big, brown house.

- Note that the value of the lat/lon is encoded within the title attribute of the abbr element: latitude semicolon longitude.
- Also note that we have extended the original HTML text with additional information (lat/lon information).

# geo Best Practice

- Example: which part of this hCard should you wrap with geo?

1. <div class="vcard">
2. <span class="fn n">
3. <span class="given-name">John</span>
4. <abbr class="additional-name" title="Quinlan">Q.</abbr>
5. <span class="family-name">Smith</span>
6. </span><br />
7. <span class="adr">
8. <span class="street-address">10 Bolyston St.</span><br />
9. <span class="locality">Boston</span>,
10. <abbr class="region" title="Massachusetts">MA</abbr>
11. <span class="postal-code">01210</span>
12. </span>
13. </div>

- Should we wrap the name, the street address, the entire address, or the whole thing? View example10 (without geo).

# geo Best Practice

- Best Practice: wrap the name:

1. <div class="vcard">
2. <abbr class="geo" title="42.352163;-71.062867">
3. <span class="fn n">
4. <span class="given-name">John</span>
5. <abbr class="additional-name" title="Quinlan">Q.</abbr>
6. <span class="family-name">Smith</span>
7. </span>
8. </abbr><br />
9. <span class="adr">
10. <span class="street-address">10 Bolyston St.</span><br />
11. <span class="locality">Boston</span>,
12. <abbr class="region" title="Massachusetts">MA</abbr>
13. <span class="postal-code">01210</span>
14. </span>
15. </div>

# hCard Mashup with Google Earth

- See hCard-to-KML tool

# hCard Mashup with Google Earth

- Here's the KML of the hCard displayed in Google Earth:

# Lab 4

- Markup this HTML text using the hCard properties. Enhance the information in this document with the lat/lon coordinates of Trump Tower (Lat: 40.762458, Lon: -73.974385).

1. <body>
2. <h1>Donald Trump</h1>
3. <p>Donald John Trump was born on June 14, 1946 (in Queens, New York) to Mary MacLeod Trump,
4. a native of Scotland, and the soon-to-be millionaire Fred Trump. Trump is an American
5. business executive, entrepreneur and author. He is the CEO of Trump Organization,
6. an American-based real estate developer in the real estate market and the founder of
7. Trump Entertainment, which operates gambling casinos. He enjoyed a great deal of
8. publicity following the success of his reality television show, The Apprentice
9. (in which he serves as both executive producer and host for the show).
10. He resides in Trump Tower at 725 Fifth Avenue at 56th Street in New York City, NY.
11. </p>
12. </body>

- Here is the HTML document: Donald-Trump.html

# Lab 4 (cont.)

- Name the new version of the HTML file: Donald-Trump-revised.html
- After marking up the HTML with the hCard properties:
  1. Validate your HTML using the W3C HTML validator: http://validator.w3.org/
  2. Use the hCard2kml.xsl tool to extract the hCard and generate a KML file. In the lab 4 folder is run.bat. Double click on it, and it will invoke the xhtml2kml.xsl tool tool.
  3. Next, download Google Earth
  4. Double click on the KML file and it will display on Google Earth!

# geo Microformat

- We have seen that geo is a "property" of the hCard Microformat.
- geo is also a standalone Microformat. It can be used on its own, independent of hCard.

# Continued ...

- Click here for Part 4 of the hCard Tutorial
- Click here for Part 1 of the hCard Tutorial
- Click here for Part 2 of the hCard Tutorial
- Click here for Part 3 of the hCard Tutorial
- Click here for Part 5 of the hCard Tutorial