I agree that it is a bad idea to rely on screen width from the client but here, for your edification:
javascript:
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","set_screen_width.php?s="+screen.width,false);
xmlhttp.send();
If you execute this script on loading the page, it will check the screen width and send it to your php file which needs to be something like:
All your other PHP pages can then access the $_SESSION variable vis:
etc...
It is better not to try to send HTML that will only look good in one screen width. You can, but it's a losing game. You just don't know what the client is going to do with it. Suppose, for instance, that they have low vision and like to use a larger font.