Skip to content

Instantly share code, notes, and snippets.

@kixxauth
Created June 27, 2011 16:13
Show Gist options
  • Save kixxauth/1049186 to your computer and use it in GitHub Desktop.
Save kixxauth/1049186 to your computer and use it in GitHub Desktop.
Conditional HTML root tag based on browser
<!doctype html>
{# <!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ --> #}
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if IE 9 ]> <html class="no-js ie9" lang="en"> <![endif]-->
<!--[if !(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<style>/* This works just as well in a stylesheet, of course */
/* @layout */
#wrapper, #errors-wrapper {
width: 920px;
margin: 0 auto;
font-size: 14px;
position: relative;
}
/* Conditionally apply a border to the wrapper for ie7 and ie8 */
.ie7 #wrapper, .ie8 #wrapper {
border: 1px solid #ccc;
}
</style>
</head><body>
<div id="wrapper">
Page content...
</div>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment