You may parse the user agent to determine the mobile platform (e.g., iPhone, iPad, iPod, Android, Opera, Android, BlackBerry, hpwOS, Windows PhoneOS, etc.).
And it is better to use a @media query in CSS to take advantage of the screen dimensions.
For reference: