It is not possible to accomplish this without resorting to Javascript at this time.
As @easwee said, Modernizr is a well-regarded JS library that focuses on feature detection. You can use its touch test for your use case.
If you do not need all the bells and whistles of Modernizr, you can do the following:
A) Download the following JS early on in your <body> , as you can:
<script type="text/javascript"> if( !!window.TouchEvent ) body.className += " touch-enabled "; </script>
B) Write your CSS. Since Gecko uses a media query to tell you about the availability of a touch, you have to trick touch CSS, for example:
BODY.touch-enabled DIV.foo { } @media screen and (-moz-touch-enabled) { DIV.foo { } }
If the code for each selector is identical in both circumstances, GZIP should optimize part of the duplication. (I hope you use compression.)
Ian wessman
source share