Can comments appear before the DOCTYPE declaration?

前端 未结 5 1819
醉梦人生
醉梦人生 2020-11-27 15:39

I would like to place a comment ( style) at the very top of my HTML code, preceding the DOCTYPE declaration. Does this conform to the standar

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-27 16:27

    Writing the first is certainly best practice.

    I remember strange problems a long, long time ago where some browser (probably IE6) ignored a because there was something seemingly innocent before it - I think just whitespace, but maybe it was a comment. In any case, it was a horrible, horrible bug to have to track down, and there's certainly never any good reason to have comments or whitespace before the .

    Writing the first is, I'd say, just something experienced web developers do to avoid horrible, elusive bugs.

提交回复
热议问题