Use attribute selector or set class name?

Should use

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

or set the class name for the input tag?

 html: <input type="submit" class="submit"> css: .submit{...} 
+4
source share
3 answers

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

This article is interesting:

+5
source

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

0
source

IMO, it all depends on what style you apply, in addition to the general browser support factors that others have already talked about. For example, if what you apply is absolutely an essential part of your design (e.g. layout), then it is probably safer to stick with the class name.

However, if you use "decorative flowering" and, in particular, if CSS, which is not even supported in older versions of IE anyway (think about the border radius, for starters), then it is better to keep your markup clean and use the attribute selector .

Under similar circumstances, you may find it worthwhile to incrementally use javascript — that is, leave the markup beautiful and clean, but add a class or inline style to the element using JS.

0
source

All Articles