Can Inline element contain Block-level element

I am learning HTML and CSS and there is a pretty common rule that Inline elements cannot contain block-level elements. This is understandable but there is a one case in my mind which is bothering me. What about p tag (block-level element) inside span tag (inline element). I know that works but is it legal? I believe need for paragraph tag inside span tag is very common but is there is a alternate solution?

We often use span tag inside the p tag and not p tag inside the span tag.
Inline elements cannot contain block level elements.

There is an exception made for the anchor element though.

1 Like