A long time ago, I've read somewhere that a good practice is to always encapsulate text with either a p or a span. For example, if putting text inside a td or li, it's a good idea to encapsulate it with p even though it doesn't have any effect.

What are your thoughts on this?

2 answers

Rob 230

It depends.

In the semantic web of today, it makes sense to enclose your text in something that makes sense. A p for text makes sense if it's a paragraph and a li if it's a list of things but a td or div may not in some cases.

Answered over 9 years ago by Rob

In most cases the only reason to put p tags inside li or td tags is if you will need to subdivide the content of that li or td.

For example if you were creating a list of projects and wanted to include a summary and sample image for each one.

The directive to encapsulate text just means that it should always have a parent. I believe this dates back to the beginning of the web when pages were mostly presenting research papers. You could technically just pour your text into the body tag and use br tags to break it up, but this has obvious drawbacks. All those tags were created to give semantic meaning to the text!

Answered over 9 years ago by Alex Taylor