Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome conditional comments

Is there such a thing as conditional comments for Chrome?

I have a page that renders differently in Chrome when compared to Firefox.

Thanks

like image 453
Razor Avatar asked Aug 18 '09 07:08

Razor


People also ask

What is conditional comments in HTML?

Conditional comments are conditional statements interpreted by Microsoft Internet Explorer versions 5 through 9 in HTML source code. They can be used to provide and hide code to and from these versions of Internet Explorer. Conditional comments are not supported in Internet Explorer 10 and 11.

What is gte in HTML?

It's a valid HTML comment so that code is hidden to non-IE browsers and IE 10 and 11 as they do not support conditional comments.


3 Answers

You can target WebKit based browsers using this in your CSS

@media screen and (-webkit-min-device-pixel-ratio:0) { 

Body {}

}

Perhaps this will help?

like image 89
George Wiscombe Avatar answered Oct 03 '22 16:10

George Wiscombe


<!--[if IE 8]><div id="bodyContainer" class="IE8"><![endif]-->
<!--[if !IE]>--><div id="bodyContainer" class="W3C"><!--<![endif]-->
<script type="text/javascript"> 
    if (navigator.userAgent.toLowerCase().match('chrome') && document.getElementById('bodyContainer'))
        document.getElementById('bodyContainer').className = document.getElementById('bodyContainer').className + " chrome";
</script>

Then you use CSS to tweak your styles specifically for Chrome.

like image 44
DmitryK Avatar answered Oct 03 '22 16:10

DmitryK


Both HTML conditional comments and Javascript conditional compilation directives are only supported by Internet Explorer 4-8 to the best of my knowledge.

like image 5
dpq Avatar answered Oct 03 '22 16:10

dpq