嵌套HTML表行元素是否可以接受?

时间:2015-11-16 18:49:33

标签: html html-table

我试图制作看起来像这样的表格: enter image description here

这是我的代码:

<table>
    <tr>
        <th></th>
        <th>Focus</th>
        <th>Impact</th>
        <th>Goal</th>
        <th>Supporters</th>
        <th>Days Left</th>
        <th>Donation Form</th>
    </tr>

    <tr>
        <tr>

            <td><a href="https://staging.dev.compassion.com/act/preview-fundraiser.htm?fid=1" class="js-campaign-title name-link ">First!</a></td>
            <td>Fundraiser</td>
            <td>$0</td>
            <td>0%</td>
            <td>0</td>
            <td>47</td>
            <td><a href="http://staging.dev.compassion.com/services/act/donationformpdfhandler.ashx?fid=1" target="_blank" title="Download the offline donation form for this fundraiser in PDF format."><i class="fa fa-file-pdf-o"></i></a></td>

        </tr>

        <tr >

            <td colspan="7"><i class="fa fa-exclamation-circle"></i> Your campaign has not been launched.</td>

        </tr>
    </tr>
</table>

但我不认为在tr中使用tr是语义的。或者是吗?我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

如上所述,你有很多标签。 我个人也会使用<thead><tbody>,但没有必要。

&#13;
&#13;
<table>
	<thead>
	    <tr>
	        <th></th>
	        <th>Focus</th>
	        <th>Impact</th>
	        <th>Goal</th>
	        <th>Supporters</th>
	        <th>Days Left</th>
	        <th>Donation Form</th>
	    </tr>
	</thead>
	<tbody>
	    <tr>
	        <td><a href="https://staging.dev.compassion.com/act/preview-fundraiser.htm?fid=1" class="js-campaign-title name-link ">First!</a></td>
	        <td>Fundraiser</td>
	        <td>$0</td>
	        <td>0%</td>
	        <td>0</td>
	        <td>47</td>
	        <td><a href="http://staging.dev.compassion.com/services/act/donationformpdfhandler.ashx?fid=1" target="_blank" title="Download the offline donation form for this fundraiser in PDF format."><i class="fa fa-file-pdf-o"></i></a></td>
	    </tr>

	    <tr>
	    	<td colspan="7"><i class="fa fa-exclamation-circle"></i> Your campaign has not been launched.</td>
	    </tr>
	</tbody>
</table>
&#13;
&#13;
&#13;