Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Shane McC
Shane McC
3,005 Points

Structured Data Markup Question?

Hi Everyone,

I'm attempting to markup my HTML in a search engine friendly way via structured data. I'm using data-vocabulary.org as a guide. My question is this, is my below markup correct? I believe it is but when I use the google structured data testing tool. It's saying their isn't any markup. What am I doing wrong? Thanks everyone.

    <div itemscope itemtype="http://data-vocabulary.org/Organization">
    <tr>
        <td><strong><span itemprop="name"><?=$dealership?></span></strong></td>
        <span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
        <td><span itemprop="street-address"><?=$address?></span></td>
        <td><span itemprop="region"><?=$state?></span></td>
        <td><span itemprop="locality"><?=$city?></span></td>
        <td><span itemprop="postal-code"><?=$zip?></span></td>
        <td><span itemprop="tel"><?=$phone?></span></td>
        <td><span itemprop="url"><a href="/dealers/dealerships.php?id=<?=$id?>">Click Here</a></span></td>
        </span>
    </tr>
    </div>

3 Answers

Kevin Korte
Kevin Korte
28,148 Points

You don't have any table tags for one, and I believe you need a table head tag as well before you start any table rows.

However, I'm not real up to speed on tables, I do think I know that much.

Shane McC
Shane McC
3,005 Points

Hi Kevin,

Thanks for your reply. Below is my full syntax with the table. Although I'm confused as to where the table head would be placed in my syntax. Would the head comprise of dealership, address, state, city, zip, phone, dealer info? Thanks for your help.

<table id='message' border='1'><tr> <th>Dealership</th> <th>Address</th> <th>State</th> <th>City</th>       <th>Zip</th> <th>Phone</th> <th>Dealer Info</th> 
       <div itemscope itemtype="http://data-vocabulary.org/Organization">
       <tr>
        <td><strong><span itemprop="name"><?=$dealership?></span></strong></td>
        <span itemprop="address" itemscope itemtype="http://data-vocabulary.org/Address">
        <td><span itemprop="street-address"><?=$address?></span></td>
        <td><span itemprop="region"><?=$state?></span></td>
        <td><span itemprop="locality"><?=$city?></span></td>
        <td><span itemprop="postal-code"><?=$zip?></span></td>
        <td><span itemprop="tel"><?=$phone?></span></td>
          <td><span itemprop="url"><a href="/dealers/dealerships.php?id=<?=$id?>">Click Here</a>  </span></td>
        </span>
    </tr>
    </div>

</table>
Kevin Korte
Kevin Korte
28,148 Points

It doesn't look like you have to have a table head, but you could put your <th> tags inside the head. So it would be something like this

<table>
    <thead>
        <tr>
            <th></th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <tr>
             <td></td>
             <td></td>
        </tr>
         <tr>
             <td></td>
             <td></td>
        </tr>
     </tbody>
</table>

This doc has all of the info on html table markup. http://www.w3.org/TR/html401/struct/tables.html#h-11.5

Also, one reason you might get a non data error on google's data testing tool is because of the variables you're using. Those likely do not hold any values inside the google testing tool.

James Barnett
James Barnett
39,199 Points

Kevin Korte - Personally I think checking the actual spec can be a bit of a steep learning curve.

First I would check HTML Dog's page on Table headers if that doesn't have enough details then I'd check out dochub's page on tables

Shane McC
Shane McC
3,005 Points

Thanks Kevin and James.

I have another question, what would actually be my head?

Would the dealership, state, city, zip, phone, dealership info be my head?

<table>
<thead>
    <tr>
        <th>Dealership</th>
        <th>State</th>
        <th>City</th> etc .....
    </tr>
  </thead>
 <tbody>
    <tr>
    <td><span itemprop="street-address"><?=$address?></span></td>
    <td><span itemprop="region"><?=$state?></span></td>
    <td><span itemprop="locality"><?=$city?></span></td>
    <td><span itemprop="postal-code"><?=$zip?></span></td> etc ......
    </tr>
     <tr>
         <td></td>
         <td></td>
    </tr>
 </tbody>
 </table>

Would this be the correct syntax?

Thanks everyone

You might want to use schema.org instead. I tested this markup stuff using Google's structured data testing tool. Hopefully it helps. Just delete the extra junk I put in for testing the tool. <table id='message'> <thead> <tr> <th>Dealership</th> <th>Address</th> <th>City</th> <th>State</th> <th>Zip</th> <th>Dealer Info</th> <th>Phone</th> </tr> </thead> <tbody itemscope itemtype="http://schema.org/LocalBusiness"> <tr itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> <td> <a itemprop="url" href="/dealers/dealerships.php?id=<?=$id?>"> <span itemprop="name"><?=$dealership?> - dealershipName</span> </a> </td> <td><span itemprop="streetAddress"><?=$address?> - address</span></td> <td><span itemprop="addressLocality"><?=$city?> - city</span></td> <td><span itemprop="addressRegion"><?=$state?> - state</span></td> <td><span itemprop="postalCode"><?=$zip?> - postalCode</span></td> <td><span itemprop="description"> - dealerInfo</span></td> <td><span itemprop="telephone"><?=$phone?> - 123.123.1234</span></td> </tr> </tbody> </table>

<table id='message'> <thead> <tr> <th>Dealership</th> <th>Address</th> <th>City</th> <th>State</th> <th>Zip</th> <th>Dealer Info</th> <th>Phone</th> </tr> </thead> <tbody itemscope itemtype="http://schema.org/LocalBusiness"> <tr itemprop="address" itemscope itemtype="http://schema.org/PostalAddress"> <td> <a itemprop="url" href="/dealers/dealerships.php?id=<?=$id?>"> <span itemprop="name"><?=$dealership?> - dealershipName</span> </a> </td> <td><span itemprop="streetAddress"><?=$address?> - address</span></td> <td><span itemprop="addressLocality"><?=$city?> - city</span></td> <td><span itemprop="addressRegion"><?=$state?> - state</span></td> <td><span itemprop="postalCode"><?=$zip?> - postalCode</span></td> <td><span itemprop="description"> - dealerInfo</span></td> <td><span itemprop="telephone"><?=$phone?> - 123.123.1234</span></td> </tr> </tbody> </table>

Ignore last post, I was trying to get the code to display properly but screwed it up. I haven't figured out how to use markdown yet.