Is it wrong to change a block element to inline with CSS if it contains another block element?

后端 未结 9 1202
遇见更好的自我
遇见更好的自我 2020-11-22 16:25

I know it\'s wrong to put a block element inside an inline element, but what about the following?

Imagine this valid markup:

This

9条回答
  •  失恋的感觉
    2020-11-22 17:11

    The HTML and the CSS will both still be valid. Ideally, you wouldn't have to do something like this, but that particular bit of CSS is actually a handy (and syntactically valid but not semantically valid) way for getting Internet Explorer's double margin bug without resorting to conditional stylesheets or hacks that will invalidate your CSS. The (X)HTML has more semantic value than the CSS, so it's less important that the CSS is semantically valid. In my mind, it's acceptable because it solves an annoying browser issue without invalidating your code.

提交回复
热议问题