Using Microdata in <table>

I am trying to add Schema.org markup to my HTML. In particular, I want to mark up some events according to these examples . While these examples are helpful, they are also somewhat incomplete, eg. the use of artist / artist properties is not demonstrated.

In my particular case, each event is represented as a table row. Before adding Schema.org properties, the markup looks like this:

    <tr id="459">

        <td class="nameCol">
            <a href="/summer-festivals/show/459/film/dublin-chinese-film-festival-2013">Dublin Chinese Film Festival 2013</a>
        </td>
        <td class="typeCol">Film</td>
        <td class="startCol">1 Feb 2013</td>
        <td class="endCol">9 Feb 2013</td>
        <td class="addressCol">Lighthouse Cinema, Smithfield Square, Dublin 7</td>
        <td class="countryCol">Ireland</td>                       
    </tr>

      

And after the first try to add Schema.org properties it looks like this:

   <tr id="459" itemscope itemtype="http://schema.org/Event">

        <td class="nameCol">
            <a href="/summer-festivals/show/459/film/dublin-chinese-film-festival-2013" itemprop="url">Dublin Chinese Film Festival 2013</a>
        </td>
        <td class="typeCol">Film</td>

        <td class="startCol">
            <meta itemprop="startDate" content="2013-02-01">
            1 Feb 2013
        </td>

        <td class="endCol">
            <meta itemprop="endDate" content="2013-02-09">
            9 Feb 2013
        </td>

        <span itemprop="location" itemscope itemtype="http://schema.org/Place">

            <span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">
                <meta itemprop="latitude" content="53.3482"/>
                <meta itemprop="longitude" content="-6.27794"/>
            </span>

            <td class="addressCol">Lighthouse Cinema, Smithfield Square, Dublin 7</td>

            <span itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
                <td class="countryCol" itemprop="addressCountry">Ireland</td>
            </span>
        </span>
    </tr>

      

There are several problems with this:

  • In Schema.org examples, there is always a root for each event <div>

    , but in my case it is a <tr>

    , is that allowed?

  • I want to include some data markup in Schema.org that is not actually displayed to users (eg latitude, longitude). I am currently doing this by adding extras <span>

    between the table cells, but this is invalid HTML.

  • Similarly, I need to wrap the country cell in in <span>

    order to properly label it from the Schema.org POV. But the markup becomes invalid from HTML POV.

+3


source to share


1 answer


Regarding 1: You can use Microdata attributes for any HTML element. So you can use elements td

. The examples always use div

/ span

because that's what will always work. It is good practice to use your existing markup instead of adding new div

/ elements span

.

As for 2: Perhaps can help here itemref

?

[...] This is just a syntactic construct to help authors add annotations to pages where the annotated data does not follow a convenient tree structure. For example, it allows authors to mark up the data in a table so that each column defines a separate item while storing properties in cells.



Regarding 3: Why don't you wrap span

in td

?

<td class="countryCol" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
  <span itemprop="addressCountry">Ireland</span>
</td>

      

+1


source







All Articles