Is there a CSS selector for elements lacking an attribute?

后端 未结 4 456
一整个雨季
一整个雨季 2021-02-04 23:44

I understand that css rules can target elements specified by attribute values, e.g.:

input[type=\"text\"] {}

Can I make a rule that targets ele

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 23:47

    For links you can simply use:

    a { color: red; }
    a:link { color: green; }
    

    fiddle: http://jsfiddle.net/ZHTXS/ no need for javascript.

    For form attributes, use the not attribute pattern noted above input:not([type]) and if you need to support older versions of IE, I'd probably add a class and use an IE specific style sheet linked with conditional comments.

提交回复
热议问题