An Introduction to

gRegor Morrill, gregorlove.com
CC-BY-3.0

What are microformats?

A simple way to mark up structural information in your HTML so software can parse it.

Core principles of microformats

  • Solve a specific, simple problem
  • Design for humans first, machines second
  • Keep it DRY
more on http://microformats.org/wiki/principles

How to publish microformats

Let's start with a contact information example:

PayLease 9330 Scranton Rd #450 San Diego, CA 92121

Add microformat class names

PayLease 9330 Scranton Rd #450 San Diego, CA 92121
h-card specification: http://microformats.org/wiki/h-card

microformats2 parsers return JSON

{
  "items": [
    {
      "type": [
        "h-card"
      ],
      "properties": {
        "org": [
          "PayLease"
        ],
        "street-address": [
          "9330 Scranton Rd #450"
        ],
        "locality": [
          "San Diego"
        ],
        "region": [
          "CA"
        ],
        "postal-code": [
          "92121"
        ]
      }
    }
  ],
  "rels": {},
  "rel-urls": {}
}

Anatomy of the markup

  • Use the class attribute
  • h- prefix for root microformats
  • p- prefix for plain text properties
  • u- prefix for URL properties
  • dt- prefix for date/time properties
  • e- prefix for embedded markup properties

Another example: events

An Introduction to Microformats

@ PayLease – San Diego, CA

I'll be giving a talk about microformats at...

h-event specification: http://microformats.org/wiki/h-event

microformats vocabularies

  • h-card
  • h-event
  • h-entry, h-feed
  • h-review
and more: http://microformats.org/wiki/microformats2

Use-cases

  • Subscribe to events in calendar software (mf2-to-iCalendar)
  • Cross-site commenting when used in conjunction with Webmention
  • Publish using third-party clients (Micropub)
  • Subscribe to h-feed in next-generation readers (Microsub)

Who publishes microformats?

  • You might already! Do you have a WordPress site?
  • micro.blog
  • Mastodon

Consuming microformats

  • mf2 parsers available in several languages including: PHP, Python, Ruby, Node, Haskell, and Go
  • Granary: a library to convert between ActivityStreams, microformats2, and Atom
  • XRay: a library to parse structured content, including microformats2

Live demo

What could go wrong?

microformats.org

We do it with class.