Nesting block level elements inside the

tag… right or wrong?

前端 未结 6 2188
遇见更好的自我
遇见更好的自我 2020-11-22 10:13

Is it syntactically and semantically correct to nest

or any other block level element inside the

tag. I am talking about HTML

6条回答
  •  遥遥无期
    2020-11-22 10:37

    It is syntactically incorrect, as you can see for yourself using the W3C markup validator.

    Semantically and practically I would say it's "ok" in the sense that a) it is very natural, b) all browsers handle it correctly (indeed this is one of the easiest problems they have to face daily).

    If your HTML is produced by user input (e.g. an HTML editor widget using which visitors can leave comments) then I 'd say simply let it be, even if it is "incorrect".

    Otherwise, you could change the markup a bit. Personally I would go with

    Some content

    and give .para appropriate margins with CSS.

提交回复
热议问题