CSS, JavaScript and XHTML Explained

Quirks, random thoughts and funky finds discovered in day-to-day coding.

 

CSS Hack for Google Chrome and Safari 3.1 September 2, 2008

Filed under: Best Practices, CSS (including hacks), Web Development — estellevw @ 9:29 pm

Valid CSS filter targeting Google Chrome and Safari 3.1

Non-compliant selectors can be used and a valid way to target individual browsers. Chrome supports every selector, just like Safari 3.1. My recommendation is to use the body:first-of-type hack, the CSS hack/filter for Safari as a filter for Safari 3+ and Chrome. There should be no reason to target Chrome with the exclusion of Safari 3.1, but if you want to target both, filtering out Safari 3.0, I would try using:

body:nth-of-type(1) p{
   color: #333333;
}

Only the Google Chrome and Safari 3.1 browsers will show paragraphs as grey. The logic is:

  • web pages only have one body element
  • only those two browsers support the pseudo-class of :nth-of-type()
  • body:nth-of-type(1) will match the first, and only, body element.

Use it as a predecessor to more specific selectors targeting the body’s children.

Share and Enjoy:
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Google
  • YahooMyWeb
 

17 Comments for this post

 
Dennison Uy Says:

Looks great on Chrome!

 
Hack CSS para Chrome — Tablosign Says:

[...] ya probaron Chrome habran notado que no renderiza como los otros navegadores. Aquí hay un pequeño hack CSS para solucionar esos pequeños errores. 0 [...]

 
kingdom media Says:

i’m willing to try it out just to see if it works more efficiently than FireFox… if it’s faster than Firefox and isn’t IE, then i’ll use it

 
Hack CSS para Chrome | Blog ZonaKaoz Says:

[...] de Google, notaras que no renderiza bien o al menos no como los demás navegadores. Pero acá un pequeño hack para solucionarlo. Tags: Chrome, CSS [...]

 
Google Chrome - jswelt - Forum (Javascript, PHP, MySQL, AJAX, Webdesign) Says:

[...] eventuell notwendig werdender CSS-Hacks schon geklrt. Safari-Anweisungen greifen hier ebenfalls: CSS, JavaScript and XHTML Explained CSS Hack for Google Chrome and Safari 3.1 Was die Zukunft betrifft, so ist es nicht unsere Aufgabe, sie vorauszusehen, sondern sie zu [...]

 
CSS Hack para Chrome y Safari | Chrome Says:

[...] que ya aparecieron los primeros hacks para homogeneizar la visualización, como la mostrada por evotech. [...]

 
麦鸡的博客 » Google Chrome的一些 Says:

[...] 大家都知道它是基于webkit的。有人已经写了它所支持的css选择器。http://www.evotech.net/blog/2008/09/google-chrome-browser-css-selector-support/,该网站也列出了chrome的css hack,当然能用在Safari。hedgerwow以前也列过一个Safari hack,当然chrome也能用。。挖挖。绕啊。 [...]

 
ExamSkills - Google Chrome Browser CSS Selector Support Says:

[...] See also: CSS Hack for Google Chrome and Safari 3.1 [...]

 
Lymorn Says:

Work’s in Opera 9.52 too :/

 
Google Chrome 周边 Says:

[...] http://www.evotech.net/blog/20…..safari-31/    body:nth-of-type(1) p{color: #333333;}             [...]

 
Vivian Crap » Blog Archive » CSS Hacks Says:

[...] CSS Hacks For Google Chrome And Safari 3.1 [...]

 
不惑仔 boohover Says:

try this,

selector:not(:root:link) {css property}

it would be better, support even to
html:not(:root:link)

till now, only safari/chrome support a sequence of simple selectors in the :not() argument such as, h1#header, div.inner, a:hover

:root:link would not exist

 
we love to create – Design | XHTML CSS | digital Lifestyle» Blogarchiv » Safari 3.1 Hack Says:

[...] funktioniert einwandfrei, spricht wohl auch Google Chrome an, ausgetestet habe ich dies wegen Nichtvorhandenseins von Chrome nicht.gefunden bei:evotech.net [...]

 
Fizzleburn » Blog Archive » CSS - targeting Chrome and Safari Says:

[...] it if you need it: http://www.evotech.net/blog/2008/09/css-hack-for-google-chrome-and-safari-31/ This entry was posted on Friday, November 14th, 2008 at 4:24 pm and is filed under CSS/Design/web. [...]

Leave a Reply