Is querySelector supported by all browsers?

IE7< don't support it and IIRC IE8 has issues with namespaces. There's at least one more esoteric browser out there with major issues but I don't recall which it is.

Basically there is no unified expression-based DOM method, and absolutely your best bet is to use a library (the ubiquitous "use jquery" answer, but you should at least check out Sizzle if you have a problem with large libraries) because rolling your own is more effort than reasonably worthwhile (I speak from experience).


QuerySelector is supported on Firefox 3.1+, IE8+ (only in IE8 standards mode), and Safari 3.1+ browsers.

supporting article


I tested it with FireFox - It is perfectly work. In IE there is a issue when you use the document with quirk mode (without using DOCTYPE HTML)

Try to use in the HTML document