Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it good to put <p> inside <td> to put content text?

Which is more semantic and valid?

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

or

<td>   content text </td> 
like image 406
Jitendra Vyas Avatar asked Dec 22 '09 04:12

Jitendra Vyas


People also ask

Can you put P inside TD?

Complete HTML/CSS Course 2022 We can easily add HTML tag inside a table. The HTML tag should be placed inside the <td> tag. For example, adding a paragraph <p>… </p> tag or other available tags inside the <td> tag.

Should I use P or div for text?

If it's paragraph of text then you should use p tag, so I would recommend to replace div to p in order to be semantically correct and help search engines better understand your content. The same way it goes for headings: if there is heading then you should use proper tag (h1 to h6 tag).

What can go inside a TD tag?

The <td> tag can contain text, form, image, table etc. The content inside it is left-aligned by default. If you present tabular data in tables than each data cell must be added individually as a <td> element.

Is it OK to put HTML tables inside P tags?

In HTML it's important to understand that P elements cannot contain other block level elements and TABLE is a block level element.


2 Answers

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>.

like image 81
Asaph Avatar answered Sep 18 '22 11:09

Asaph


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.

like image 33
netrox Avatar answered Sep 21 '22 11:09

netrox