MozillaZine

Vendor specific CSS media queries (browser hacks)

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
andrewg_scss

User avatar
 
Posts: 213
Joined: October 23rd, 2003, 10:42 am
Location: Perth, Australia

Post Posted September 23rd, 2005, 10:15 am

Now, this is a good idea!

I'd change it a little, though. "hack" has such ugly connotations. A quick check of the CSS grammar found that media types follow the "ident" syntax. What that means is that the existing convention for vendor-specific CSS properties may be followed here too, i.e. "-moz", "-o", "-khtml". ("-msie"?)

For example:
Code: Select all
@import url(operasp.css) -o-screen,-o-projection;
@import url(mozscreen.css) -moz-screen;

@media -msie-print {
  /* MSIE print styles */
}

<link rel="stylesheet" type="text/css" media="-khtml-all" href="khtml.css" />

I think that looks much better, is consistent with the existing conventions, and allows targetting of styles to specific rendering engines. However, given the original suggestion was made in 2002, I don't hold much hope of this happening soon. :(

Is this the right place to suggest these sort of enhancements?
Andrew

Thumper

User avatar
 
Posts: 8037
Joined: November 4th, 2002, 5:42 pm
Location: Linlithgow, Scotland

Post Posted September 23rd, 2005, 10:23 am

Bugzilla is much more appropriate.

- Chris

jqp

User avatar
 
Posts: 5070
Joined: November 17th, 2004, 10:56 am
Location: In a box

Post Posted September 23rd, 2005, 10:26 am

If browsers follow standards, this shouldn't be necessary, right? Why muddy the water more?

old np
 
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted September 23rd, 2005, 10:43 am

jonnyq wrote:If browsers follow standards

They don't.

jqp

User avatar
 
Posts: 5070
Joined: November 17th, 2004, 10:56 am
Location: In a box

Post Posted September 23rd, 2005, 10:48 am

Then shouldn't the effort be to encourage browsers to follow standards rather than introducing more browser sniffing stuff?

andrewg_scss

User avatar
 
Posts: 213
Joined: October 23rd, 2003, 10:42 am
Location: Perth, Australia

Post Posted September 23rd, 2005, 11:04 am

It's not browser sniffing, it's just having each vendor recognizing their prefix (like Mozilla browsers already have -moz). They already ignore media they don't understand, so they'd automatically ignore other vendor (-o, -khtml) prefixed media.

It recognizes that while browsers may all be striving to be standards-compliant, each will have their own bugs, and implement their own sub-set of the standards. A complete bug-free CSS3 implementation is a long way off!

I'll investigate bugzilla tomorrow, it's too late here - I need sleep!

dakboy
 
Posts: 3451
Joined: November 30th, 2002, 12:30 pm

Post Posted September 23rd, 2005, 12:01 pm

CSS already has concessions for vendor-specific properties. Leave it at that - if you have vendor-specific stuff you want in a particular media, then put them in a CSS file for that media.

Let's get browser obeying the standards that do exist before encouraging them to ignore those and write their own. We've already been down that road, from 1997 through 2003 and learned that it just isn't worth it.

andrewg_scss

User avatar
 
Posts: 213
Joined: October 23rd, 2003, 10:42 am
Location: Perth, Australia

Post Posted September 23rd, 2005, 8:39 pm

Maybe it would help if I described what I was trying to do: deliver display:inline to some browsers and display:inline-block to others. Hint: Firefox doesn't support inline-block, and MSIE barfed up the page I was working on with inline-block. So inline for those, inline-block for the rest.

I'm not trying to group vendor specific CSS properties off into particular files. I'm trying to find a way to deliver specific CSS rules, vendor-specific or otherwise (i.e. standards compliant), without browser sniffing, and conforming, as close as possible, with established (W3C) methods for browser-specific functions.

This is a suggestion for better handling the real web, where different browsers are, well, different. I hope I get more open minds on bugzilla.

andrewg_scss

User avatar
 
Posts: 213
Joined: October 23rd, 2003, 10:42 am
Location: Perth, Australia

Post Posted September 23rd, 2005, 9:06 pm

Actually, what would be even better would be for browsers to always recognize and accept their vendor specific prefix. That way I could have simply done:
Code: Select all
foo {
  display: inline;
  -khtml-display: inline-block;
}
Actually, I might just forget about bugzilla, it's sounding more like something to approach the W3C CSS group with.

peter.reisio

User avatar
 
Posts: 3166
Joined: March 3rd, 2004, 6:57 pm

Post Posted September 24th, 2005, 4:04 am

The "real web" is doing quite well without the use of proprietary tags at this point. Let's not regress it.

andrewg_scss

User avatar
 
Posts: 213
Joined: October 23rd, 2003, 10:42 am
Location: Perth, Australia

Post Posted September 24th, 2005, 10:28 am

Well, it seems these days that every site I "look under the hood" and inspect the CSS, I see voice-model hacks, comment hacks, underscore hacks, etc. I find it hard to believe that the best methods available today to handle browser differences are either user agent sniffing, or dependencies on parsing bugs. Surely something more reliable and standardised can be developed?

It's not like my suggestion is something totally new and different. Firefox, Safari, Opera, and Konqueror all support vendor prefixes now, today. What I'm suggesting is to take this existing use and convention, which is also documented in the CSS specs, and make it more useful.

Unless, of course, someone can come up with a better idea?

Cyberman

User avatar
 
Posts: 324
Joined: December 18th, 2004, 2:06 pm

Post Posted September 24th, 2005, 1:31 pm

There is only one reliable, safe way - support the standard.

No matter how "well documented", a vendor-specific rule will only work with their product. So what if someone develops a new client - is it supposed to break all sites, or emulate the behaviour of all other clients?

If at all, I´d suggest something similar to IEs conditional comments. It´s dirty as well, but more reliable than hacks. Kind of browser-sniffing, though.

If possible, a site should simply follow the rules and let those who don´t support the standards break. Of course, this isn´t possible with any site, though the idea would be nice, IMO.
HTML is defined by the W3C, not by a browser. <- I reject HTML5 for that reason. Making the fox guard the henhouse "because he's always been there anyway" isn't a good idea.

andrewg_scss

User avatar
 
Posts: 213
Joined: October 23rd, 2003, 10:42 am
Location: Perth, Australia

Post Posted September 24th, 2005, 10:45 pm

Sure, following standards is the safest, most reliable way. Just one problem - it doesn't (edit: *always*) work! The widespread use of hacks is ample evidence of that.

I fully expect most browsers to follow the standards. The problem is the odd corner cases where just one or two browsers aren't up to scratch and need a little help. The whole point of my suggesting vendor specific rules was so they recognized only rules for them. So what if a new client is developed? How would that break anything? They would be ignoring rules for other vendors, and reading the standard rules.

As for IE conditional comments, I use them myself. Very handy. But what about my original problem? I had 100% valid, standard CSS that worked in IE, Firefox, and Opera, but not Safari or Konqueror. Where are the "Safari conditional comments"?

What I'm suggesting is effectively "browser X conditional comments". Browsers would ignore properties with a vendor prefix that isn't theirs, just like non-IE browsers ignore IE conditional comments.

umkahx
 
Posts: 2
Joined: November 10th, 2014, 1:33 am

Post Posted November 10th, 2014, 1:36 am

For firefox there are several CSS hack to catch particular version, here is exampe:[url=http://basicuse.net/articles/pl/textile/html_css/css3_multiple_backgrounds]CSS hacks for Mozilla Firefox, Opera, Safari and Internet Explorer[/url].
I am talking about:
[code]
body:empty #mozilla-firefox12
[/code]
and
[code]@-moz-document url-prefix()[/code]

LIMPET235
Moderator

User avatar
 
Posts: 38674
Joined: October 19th, 2007, 1:53 am
Location: The South Coast of N.S.W. Oz.

Post Posted November 10th, 2014, 1:41 am

Locking due to old age.
Ancient Amateur Astronomer
Win-7-HP/Intel® DualCore-2.0GHz/500G HDD/4 Gig Ram/550Watt PSU/350WattUPS/Firefox-20.0-57.0-61.0-62.0/T-bird-2.0.0.24/SnagIt-v10.0.1/MWP-7.11.0.
(Always choose the "Custom" Install.)

Return to Web Development / Standards Evangelism


Who is online

Users browsing this forum: No registered users and 2 guests