Why can I not group browser-specific CSS-selectors for different browsers?

前端 未结 3 717
庸人自扰
庸人自扰 2021-01-12 22:11

I just tried to write the following rule to style the input placeholder for browsers that support it:

#main input::         


        
相关标签:
3条回答
  • 2021-01-12 22:17

    If one selector in a group of selectors is invalid, the browser must treat the entire rule as invalid. Or at least so says the W3C.

    I'm not sure why this behaviour is mandated, but at a push, I'd guess it's because an invalid selector could break general CSS syntax, making it impossible for a browser to reliably guess where the invalid selector ends and valid elements begin.

    0 讨论(0)
  • 2021-01-12 22:23

    If you are willing to use JavaScript, check out the -prefix-free script. It allows you to leave off the vendor specific prefixes (e.g. -webkit- or -moz-) for CSS properties like these.

    0 讨论(0)
  • 2021-01-12 22:24

    Most likely, some browsers discard the entire definition because they don't consider the selector valid.

    0 讨论(0)
提交回复
热议问题