书写css伪类时冒号前或后多个空格导致该规则失效

相信多数开发者不会多个空格。
偶然发现的,网上多数css格式化将压缩后的css格式化后会发生这个情况。

搜“css格式化”,以下网站

http://www.jb51.net/tools/cssyasuo.shtml
http://www.ttmouse.com/geshi.html

格式化后会多出个空格,多出空格后样式规则失效了。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>书写css伪类时冒号前或后多个空格导致该规则失效</title>
        <style type="text/css">
            a:link {
                color: gray;
            }
            a:visited {
                color: red;
            }
            /* 冒号后多了个空格 */
            a: hover {
                color: yellow;
            }
        </style>
    </head>
    <body>
        <a href="http://www.sina.com.cn">sina</a>
    </body>
</html>

所有浏览器中测试hover规则没起作用。

在冒号前多了个空格也一样。

须注意..

原文地址:https://www.cnblogs.com/snandy/p/2003021.html