Skip to main content
Active reading [<http://en.wikipedia.org/wiki/World_Wide_Web_Consortium> <http://en.wikipedia.org/wiki/XHTML>].
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 109
  • 132

Why can't the <p> tag can't contain a <div> tag inside it?

As far as I know, this this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
  <div>some words</div>
</p>

The first one can pass the w3c validatorthe W3C validator (xhtmlXHTML 1.0), but the second can't. I I know that nobody will write code like the second one. I just want know why. And

And what about other tags' containment relationship?

Why <p> tag can't contain <div> tag inside it?

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
  <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship?

Why can't the <p> tag contain a <div> tag inside it?

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
  <div>some words</div>
</p>

The first one can pass the W3C validator (XHTML 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why.

And what about other tags' containment relationship?

Fix indentation
Source Link
tanguy_k
  • 11.8k
  • 6
  • 58
  • 61

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
    <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship?

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
    <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship?

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
  <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship?

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
    <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship? Thank you.

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
    <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship? Thank you.

As far as I know, this is right:

<div>
  <p>some words</p>
</div>

But this is wrong:

<p>
    <div>some words</div>
</p>

The first one can pass the w3c validator (xhtml 1.0), but the second can't. I know that nobody will write code like the second one. I just want know why. And what about other tags' containment relationship?

Source Link
Henry H Miao
  • 3.5k
  • 4
  • 22
  • 27
Loading