What exactly does the 'only' keyword do in CSS media queries?

前端 未结 2 1277
旧时难觅i
旧时难觅i 2020-12-30 06:29

On Mozilla\'s page about media queries, it says:

The only keyword hides style sheets from older browsers that don\'t support media queries:<

2条回答
  •  轮回少年
    2020-12-30 06:56

    My guess is that certain pre-CSS3 browsers, which understand only media types, interpret

    media="screen and (color)"
    media="screen" // `screen` is a known media type; ACCEPT for screen media
    

    and

    media="only screen and (color)"
    media="only"    // `only` is an unknown media type
    media="unknown" // REJECT for any media
    

    Essentially they ignore everything after the first space but treat the remainder as valid.

提交回复
热议问题