结构化数据和HTML表格

时间:2018-09-19 22:13:17

标签: html seo semantic-markup

我正在建立一个HTML表,该表必须是SEO和Google结构化数据友好的。 请参阅此处作为我的示例:

<table>
  <thead>
    <tr role="row">
      <th>Brand</th>
      <th>Car</th>
      <th>Price (USD)</th>
    </tr>
  </thead>
  <tbody>
    <tr role="row">
      <td data-th="Brand">
        Mercedes
      </td>
      <td data-th="Car">
        Mercedes-Benz Maybach Exelero
      </td>
      <td data-th="Price (USD)">
        $8,000,000
      </td>
    </tr>
		<tr role="row">
      <td data-th="Brand">
        Lamborghini
      </td>
      <td data-th="Car">
        Lamborghini Veneno Roadster
      </td>
      <td data-th="Price (USD)">
        $4,500,000
      </td>
    </tr>
		<tr role="row">
      <td data-th="Brand">
        Lykan
      </td>
      <td data-th="Car">
        Lykan Hypersport
      </td>
      <td data-th="Price (USD)">
        $3,400,000
      </td>
    </tr>
		<tr role="row">
      <td data-th="Brand">
        Ferrari
      </td>
      <td data-th="Car">
        2015 Ferrari FXX K
      </td>
      <td data-th="Price (USD)">
        $3,100,000
      </td>
    </tr>
  </tbody>
</table>

还有其他方法可以制作Google结构化数据表吗?不是使用表结构,而是使用div并将正确的结构化数据添加到表结构中?

1 个答案:

答案 0 :(得分:0)

尝试用此方法代替表td。

  .table{
    display:table;
  }
  .table-row{
    display: table-row;
  }
  .table-row div{
    display: table-cell;
  }
<div class="table"> 
      <div role="row" class="table-row">
        <div>Brand</div>
        <div>Car</div>
        <div>Price (USD)</div>
      </div>
      <div role="row" class="table-row">
        <div data-div="Brand">
          Mercedes
        </div>
        <div data-div="Car">
          Mercedes-Benz Maybach Exelero
        </div>
        <div data-div="Price (USD)">
          $8,000,000
        </div>
      </div>
      <div role="row" class="table-row">
        <div data-div="Brand">
          Lamborghini
        </div>
        <div data-div="Car">
          Lamborghini Veneno Roadster
        </div>
        <div data-div="Price (USD)">
          $4,500,000
        </div>
      </div>
      <div role="row" class="table-row">
        <div data-div="Brand">
          Lykan
        </div>
        <div data-div="Car">
          Lykan Hypersport
        </div>
        <div data-div="Price (USD)">
          $3,400,000
        </div>
      </div>
      <div role="row" class="table-row">
        <div data-div="Brand">
          Ferrari
        </div>
        <div data-div="Car">
          2015 Ferrari FXX K
        </div>
        <div data-div="Price (USD)">
          $3,100,000
        </div>
      </div>
    </div>