Search code examples
htmlcssconditional-statementsscreen-resolution

conditional statement for screen resolution?


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


Solution

  • 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.