March 13, 2012

How to target tablet devices with CSS queries

Question by Dude

I am trying to target tablets with a own css however I do not get it to work. I know there is a way to target iPad specifically but are there no better ways? I want to target Android tablets too but phones such as Samsung Nexus are misinterpreted as a tablet in the way I am doing it now.

Answer by Tarun

you need to use different style sheets according to device resolution

<link rel="stylesheet" media="all" href="style.css">
<link rel="stylesheet" media="screen and (max-device-width: 320px)" href="mobile.css">
<link rel="stylesheet" media="screen and (min-width: 641px) and (max-width: 800px)" href="tablet.css">

Answer by Starx

The best way I think is media queries. And there are lots of scripts, which enable the media queries.

Response.js

It has been also included in modernizr. So, you can use which you prefer.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!