tags:

views:

35

answers:

3

Should we use

css: input[type='submit']{...}

or set class name for input tag?

html: <input type="submit" class="submit">
css: .submit{...}
+4  A: 

You should use the class name instead of attribute selector if you want to support IE6.

This article is interesting:

Sarfraz
But if IE6 is deprecated even from the vendor, why should we continue to support it? There comes a point where old cars are scrapped, old roads are repaved, old water mains are replaced, and old telephone lines ... wait, those aren't ever repaired. ~~ I realize this is a religious debate, to support IE6 or to not support IE6, but for most people today, IE6 is not a good reason to stick with backwards compatibility. But +1 for a valid point. I just disagree with the point.
drachenstern
@drachenstern: It is personal choice whether you want to support IE6 or ignore it. I support it where possible :)
Sarfraz
+1 to drachenstern. People have to let IE6 die. I'm still amazed by the fact that some people really use it.
Octavian Damiean
@MAINERROR: We all hate IE6 and some even go on to hating all versions of IE but we can do nothing if our users are using it :( Secondly, it is up to OP whether or not he wants to support IE6 :)
Sarfraz
@Sarfraz: Definitely I'm not saying anything else. I was more a general rant. :)
Octavian Damiean
A: 

Yes, As Sarfraz said if you go for browser compatibility you should go for class name, but attribute selector provides a vast range of control over any elements.

Starx
What do you mean by vast range of control?
Sarfraz
I think he means that attribute selectors allow you to make more granular selections without needing to pepper your html with extra/redundant classes.
Ax
A: 

IMO, it all depends on exactly what style you're applying - in addition to the general browser support factors that others have already mentioned, of course. For example, if what you're applying is an absolutely core part of your design (e.g. layout), then it's probably safest to stick with a class name.

However, if what you're applying is a 'decorative flourish' and, in particular, if it's CSS that isn't even supported in older versions of IE anyway (think border-radius, for a start) then it's much better to keep your markup clean and make use of the attribute selector.

Under similar circumstances, you may deem it worthwhile to progressively enhance via javascript - i.e. leave the markup nice and clean but add a class or inline style to the element using JS.

Bobby Jack