views:

33

answers:

2

I would like to use a conditional statement to attach a different stylesheet for:

if the clients resolution is <= 1024*768

I'm pretty sure this is possible, but have never seen the code for it before?

ps. I am not looking for a javascript solution

+1  A: 

No, it's not possible with CSS. The only way is to alter elements with a javascript.

munissor
+2  A: 

CSS 3 introduces media queries, but it is new and support is not all that widespread yet (Firefox only introduced it in version 3.5, for instance, and Internet Explorer won't get it until version 9) so build with progressive enhancement in mind. CSS Tricks has a tutorial for providing different CSS for different browser window sizes (which is a more useful metric then display resolution).

You can test support for your browser.

David Dorward
yeah, it's a shame that there's a strong correlation between 1024*768's and old browsers (no css3)! - with netbooks on the rise res-css correllation may change
Haroldo
So build for narrow displays, and use a media query to detect wider windows and override the layout.
David Dorward