把
放在前面好不好?里面
哪个更语义和有效?
<td>
<p>
content text
</p>
</td>
或者
<td>
content text
</td>
Which is more semantic and valid?
<td>
<p>
content text
</p>
</td>
or
<td>
content text
</td>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
除非表格单元格的内容真正是一个段落,否则请省略
标记。当然可以在表格数据中包含段落,在这种情况下,将适当地放置语义
。但是对于单元格中包含数据的公用表,例如。数字、名称等,不包括
。
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>
.这取决于你的意图。如果单元格只有一个段落,则向其中添加
标记是没有意义的。
如果您打算在
单元格中包含几个段落,那么使用
标记是有意义的。
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.它们都是有效的。但是,如果您打算有多个段落,显然请使用
标签
They are both valid. However, if you are going to have multiple paragraphs, obviously use the
<p>
tags如果表格单元格数据是文本:
如果表格单元格数据是段落:
If the tabular cell data is text:
If the tabular cell data is paragraph(s):
两者均有效;如果这是
的唯一内容,并且该内容未在 JavaScript 代码中使用,则第二个更好。
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.取决于您是否订阅“表格用于表格数据”或“表格用于布局”学派。如果您更喜欢将表格用于表格数据,并且段落不是表格数据,则“p”有效,如果表格用于布局,并且您为其他布局语义保留了“p”标记,则不需要它。
简短的回答是,这完全取决于你。 :)
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. :)