Is it good to put

inside to put content t

2019-04-03 05:15发布

Which is more semantic and valid?

<td> 
<p>
 content text
</p>
</td>

or

<td> 
 content text
</td>

6条回答
Summer. ? 凉城
2楼-- · 2019-04-03 05:30

Both are valid; if that is the only content of <td>, and the content is not being used in JavaScript code, then the second is better.

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-04-03 05:32

Depends on if you subscribe to the "tables are for tabular data" or the "tables are for layout" school. If you prefer to use your tables for tabular data, and the paragraph is not tabular data the "p" is valid, if tables are for layout, and you have the "p" tag reserved for other layout semantics then its not required.

Short answer is, its really up to you. :)

查看更多
兄弟一词,经得起流年.
4楼-- · 2019-04-03 05:34

They are both valid. However, if you are going to have multiple paragraphs, obviously use the <p> tags

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-04-03 05:38

It depends on your intention. If the cell is going to have just ONE paragraph then it makes no sense to add the <p> tag to it.

If you intend to have a few paragraphs in the <td> cell then it makes sense to use the <p> tag.

查看更多
冷血范
6楼-- · 2019-04-03 05:46

Leave out the <p> tag unless the content of your table cell is truly a paragraph. It's certainly possible to have paragraphs in tabular data, and in that case a semantic <p> would be appropriately placed. But for the common table with data in the cells eg. numbers, names, etc., don't include the <p>.

查看更多
Evening l夕情丶
7楼-- · 2019-04-03 05:46

If the tabular cell data is text:

<td> 
 content text
</td>

If the tabular cell data is paragraph(s):

<td> 
<p>
 content text
</p>
...
</td>
查看更多
登录 后发表回答