DIV tag inside of P looking weird in the DOM tree

Looking at any web inspector, the following markup is outputting unexpected (at least to me) results:

<p>
    <div>Here's a div!</div>
    And here's some text. 
    <div>Here's another div!</div>
</p>

Using Chrome's Dev Tools, I'm seeing the DOM tree look like this:

Maybe I'm having a brain fart, but shouldn't the DIV be inside of the P tag?

Answers


It is not valid html to put a <div> inside a <p>. The <p> element is only meant to include inline elements. <div> is a block element. See section 9.3.1 of the HTML Specification for more info.

Chrome will sometimes rewrite bad HTML to be valid.

Here is a related/duplicate question.


Need Your Help

Increment an int stored in a generic type

java generics increment

If I have an int stored in a generic type, say V, what is the best way to increment that value? For example, the code below will obviously not work.

#ifdef with gfortran 77

debugging preprocessor fortran77 conditional-compilation

I am using gfortran to compile FORTRAN 77 and would like to have DEBUG build options by using the preprocessor directive #ifdef. However, when I use them I get compile time warnings "Illegal