Target specific browsers in CSS with JS


/ Published in: JavaScript
Save to your folder(s)

Will produce output like this:


...



...




Target in CSS like this:

html[data-useragent*='Chrome/13.0'] .nav {background:url(img/radial_grad.png) center bottom no-repeat;}

or

html[data-useragent*='Chrome/13.0'][data-platform='Win32'] {}

or iPad only
html[data-platform='iPad']


Copy this code and paste it in your HTML
  1. <script>
  2. var b = document.documentElement;
  3. b.setAttribute('data-useragent', navigator.userAgent);
  4. b.setAttribute('data-platform', navigator.platform );
  5. </script>

URL: http://rogieking.com/post/9089341529/html5boilerplatejs

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.