Can the "p" tag hold other than just text elements


The more I read about HTML and CSS the more I know how much I dont know. I was trying to incorporate a search box in one of my sites and I was searching on the internet to see what was the most appropriate way to create this and to my surprise I came across a tutorial that actually show the input field surrounded with a “p” tag. Something like this…

<form action=" method="get">
 <p>Search:<input type="submit"></p>

Can the P tag hold other than just text elements? If yes, when would you do this and why?

Thanks a lot!

Yes, the P element can contain other elements as it is block-level, for example P can contain the inline SPAN. Albeit I think you were actually asking why is there a P as a direct descendant of the FORM in that example?

Well, I’d say probably because they (see example post #1) aren’t bothered about semantics. It’s not a very good use of semantics I suspect they didn’t even use LABEL in the full form, etc.

The main restriction is that paragraphs should not contain block-level elements.

See the HTML 4.01 spec

Thanks a lot guys!

No problem dude.