Return to Snippet

Revision: 51275
at September 20, 2011 03:40 by reverend


Initial Code
<script>
  var b = document.documentElement;
  b.setAttribute('data-useragent',  navigator.userAgent);
  b.setAttribute('data-platform', navigator.platform );
</script>

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

Initial Description
Will produce output like this:

<html>
	...
</html>

<html>
	...
</html>



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']

Initial Title
Target specific browsers in CSS with JS

Initial Tags
css, js, browser

Initial Language
JavaScript