tags:

views:

45

answers:

3

can we have content text directly in <div>text content</div> or it should be like <div><p>text content</p></div>? according to web standards.

+2  A: 

You can have it directly in a div. The div is often used to group block-elements to format them with styles, but normal, unmarkedup text in a div is just fine.

karim79
A: 

The standards are not so well defined. I would choose your second example, because it is more structurally sound, and therefore more semantic.

+1  A: 

You can have character data directly inside a div element. If (and only if) that character data is a paragraph, then it should also be marked up as a paragraph (as per your second example). If you only have one paragraph of content inside the div, then you should usually avoid having the div element as it serves no purpose.

David Dorward
thanks for answer. What W3c says regarding this?
metal-gear-solid