Why does “<! --” comment out a style rule, but “<!--” does not?

后端 未结 3 890
灰色年华
灰色年华 2021-02-19 03:17

Take it easy on me. I am just learning HTML.

Accroding to http://www.w3.org/TR/html-markup/syntax.html#comments and many other sites I\'ve seen such as this http://www.w

3条回答
  •  情歌与酒
    2021-02-19 03:54

    I've seen people use in CSS style block for compatibility purpose.

    In this case, old browsers that don't support CSS will comment it out to avoid errors.

    
    

    will be interpreted as

    
    

    by old browsers that don't support CSS. This way these browsers avoid potential errors.

    In modern browsers however, inside CSS style block will be ignored.

    
    

    will be interpreted as

    
    

    by browsers with CSS support.

提交回复
热议问题