Table of Contents

extending_safari

Posted 2003-01-10 @ 01:06:36

Mark Pilgrim has suggested that the Safari developers should help authors embrace the new browser by including some way to target it with specific CSS to work around its various bugs, either by intentionally disabling its support of some obscure CSS syntax, or building in support for some form of invalid, non-standard CSS that only Safari would recognize.

Let me just say straight away that intentionally disabling support of valid CSS selectors is a horrible idea, and I hope the Safari team doesn't even consider it.

Adrian Holovaty suggests using standardized comments to hide rules found between two comments:


/* Begin Safari v1.0 hide */
styles_to_be_hidden {
...
}
/* End Safari v1.0 hide */

I think this is a reasonable approach, similar to Microsoft's conditional comments, and could be utilized to allow Safari-specific rules to be added to the style sheet:


/* show-safari-1.0

...Safari-specific CSS...

*/

Scott Reynen's idea of using 'fake' selectors could be problematic, as I don't know how UAs are supposed to deal with invalid selectors. However, the CSS Spec is clear as to how unknown properties are handled: the declaration is to be ignored. The Mozilla team exploited this when implementing the -moz-* series of proprietary CSS properties.

I've no idea if this is feasible, but I can see where the ability to prepend any valid property with -saf1.0- to tweak a ruleset for Safari would be fantastic for authors.

Another possibility would be the inclusion of a Safari-specific at-keyword, as UAs are supposed to ignore the entire block when encountering unknown at-rules. So, authors could add something like this so their style sheet:


div { color: blue; }
@safari {
    #foo { color: red; }
    #bar { color: red; }
    }
p { color: blue; }

And, DIVs & Ps would be blue in all browsers, while the declarations for #foo & #bar would only be honored by Safari.

Allegedly, Dave Hyatt is still undecided as to whether the idea of crippling (or extending) Safari is a Good Thing™, so we'll just have to wait & see how this plays out. Me? I'm all for extending the browser, at least until it's out of beta.