Is it valid as per html 4.01 strict?

Hi All

HTML 4.01 spec says, when ins / del is used like an inline element ( ie inside <p> ), you can’t use block level elements inside it. Even sitepoint html reference tells the same as below

“a ins element can’t contain block-level child elements when it’s used in a context that would make it inline (for example, an ins contained inside a p can’t contain a block-level element).” - Sitepoint html reference

But when I validate the below code, w3 validator for 4.01 strict don’t show any error.

   <p><ins>now i am a <div>inline</div> element</ins></p>

Am I missing anything or a bug in w3 validator?

Thanks AutisticCuckoo!

It could be considered a bug in the validator, but it’s really a limitation in DTD syntax. It simply isn’t possible to specify this rule.

The ins and del element types are specified as inclusions on the body element:

<!ELEMENT BODY O O (%block;|SCRIPT)+ [color=red]+(INS|DEL)[/color] -- document body -->

This means ins and del are valid anywhere inside the body element or a descendant element. And since these elements must be able to contain anything, they’re declared like this:

<!ELEMENT (INS|DEL) - - (%flow;)*      -- inserted text, deleted text -->

Put together, this causes the validator to believe that block-level elements are always allowed inside ins and del. The additional restriction that they can only contain inline elements if used as inline elements themselves is only specified in prose, since it’s not possible to state in DTD syntax.

as always, a very valid explanation came from AutisticCuckoo, no voodoo talk. thank you.

i would add the flow definition:

<!ENTITY % flow “%block; | %inline;”>

from this context

<!–================== HTML content models ===============================–>

<!–
HTML has two basic content models:

    %inline;     character level elements and text strings
    %block;      block-like elements e.g. paragraphs and lists

–>

<!ENTITY % block
“P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS”>

<!ENTITY % flow “%block; | %inline;”>

but this is just to make it like an idiots guide :slight_smile:

now, all this put together with the <p> definition gives us that prose:

<!ENTITY % flow “%block; | %inline;”>

<!ELEMENT (INS|DEL) - - (%flow; )* – inserted text, deleted text –>

<!ELEMENT P - O (%inline; )* – paragraph –>
[…]
The P element represents a paragraph. It cannot contain block-level elements (including P itself).

beside what specs are telling us, about the use of <ins> and <del> in inline content; <p> element only allows inline content, so any other elements inside a <p> that can have flow content (block or inline) should be limited to the second part: inline.

thanks again AutisticCuckoo for making me see things as they are. this only shows once again that the validation icon is only what a shiny object is to a crow. a normal developer should rise above this pretending.

The <div> tag is invalid inside the <p> tag but because you have the <ins> tag in the way the validator cannot detect that error. The validator doesn’t detect every invalid situation in the HTML, it just checks those that are easy to test and nesting involving multiple tags is one that it doesn’t test.