When it comes to dealing with cross-browser support for attribute selectors in 2014, the main concern arises if you are still working on outdated code that depends on quirks mode IE or older versions of browsers. It is true that attribute selectors do not function properly on IE6.1
If the intention behind using "class1" is to only target input[type=text]
elements, and "class2" to solely identify input[type=submit]
elements, then there isn't much distinction between utilizing a class selector or an attribute selector.2 If you are dealing with legacy code, opting for classes instead of attributes is acceptable. However, unless the classes serve another purpose like aiding a script, they end up being redundant.
Which method is quicker? It's hard to determine. Browsers tend to have specific optimizations for rules with single class selectors, but whether this actually results in saved time is debatable and not worth dwelling on unless selectors are hindering performance significantly.
1 Many individuals emphasize that attribute selectors work on IE7 and IE8 only when a doctype is included, though this applies to nearly all versions of IE. Moreover, if you aren't using a doctype already, there is likely a valid reason for it, indicating that modern CSS features should not be on your radar.
2 It's important to remember that selecting .class1
rather than input.class1
will lead to a decrease in specificity due to the absence of the input
selector.