What does the smiley face “:)” mean in CSS?

后端 未结 2 1224
旧巷少年郎
旧巷少年郎 2021-01-29 17:35

I spotted this CSS code in a project:

html, body { :)width: 640px;}

I have been around with CSS for a long time now but I never saw this \":)\"

2条回答
  •  一整个雨季
    2021-01-29 18:10

    It looks like a CSS hack to target IE7 and earlier browsers. While this is invalid CSS and browsers should ignore it, IE7 and earlier will parse and honor this rule. Here is an example of this hack in action:

    CSS

    body {
        background: url(background.png);
        :)background: url(why-you-little.png);
    }
    

    IE8 (ignores the rule)

    Example 1 - IE8

    IE7 (applies the rule)

    Example 1 - IE7

    Note that it does not have to be a smiley face; BrowserHacks mentions:

    Any combination of these characters:
    ! $ & * ( ) = % + @ , . / ` [ ] # ~ ? : < > |
    [before the property name will work on] Internet Explorer ≤ 7


    The GAH hot dog stand example is here.

提交回复
热议问题