Reputation: 1539
I want a shadow below div called "shadow":
#shadow { box-shadow: 1px 1px 1px #000 };
Done?
Not at all. It works just in one browser. Guess which one.
For FF/Chrome I have to add not too intuitive:
-moz-box-shadow: 1px 1px 1px #000;
-webkit-box-shadow: 1px 1px 1px #000;
And now everything is ok. This scheme applies to MANY CSS properties. Why?
Luckily there's no -webkit-border, moz-font or -ie-backgroundcolor.
PS. Yes, not a single word about IE. Calling THIS a browser is like comparing wheelchair to Modena cars.
PS 2. Why there is a logo next to Google Chrome tag below my post? Or why there are no logos for Opera & FF?
Upvotes: 5
Views: 380
Reputation: 168685
As others have already answered, it is because they are implementing a feature for which the specifications are not yet complete, or a feature for which their implementation is not yet complete.
This is intentional behaviour; the CSS spec specifies that this is how they are supposed to do things in this case. The reasons for this rule are as follows:
-moz-border-radius
worked quite differently to -webkit-border-radius
; there were significant syntax differences between them, so if they'd both been just border-radius
, you wouldn't have been able to support them both.Upvotes: 0
Reputation: 114367
The abilities of the browsers are ahead of the standards they're supposed to follow. They give you access to the abilities in the interim until the standard is published, then they follow the published standard and provide back-compatibility with the funky-looking "webkit..." formats.
Upvotes: 0
Reputation: 3904
It's a way for browsers to release features before the CSS Spec is fully approved.
For instance, look at the CSS3 gradients. -moz- vs -webkit- are completely different.
background-image: -webkit-gradient(
linear,
left bottom,
left top,
color-stop(0.15, rgb(145,4,88)),
color-stop(0.58, rgb(174,30,115)),
color-stop(0.79, rgb(209,57,150))
);
background-image: -moz-linear-gradient(
center bottom,
rgb(145,4,88) 15%,
rgb(174,30,115) 58%,
rgb(209,57,150) 79%
);
This may be of interest: http://www.alistapart.com/articles/prefix-or-posthack/
So the next time you find yourself grumbling about declaring the same thing four times, once for each browser, remember that the pain is temporary. It’s a little like a vaccine—the shot hurts now, true, but it’s really not that bad in comparison to the disease it prevents. And in this case, you’re being vaccinated against a bad case of multi-year parser hacking and browser sniffing. We suffered through that long plague once already. Prefixes will, if used properly, ward off another outbreak for a long time to come.
NOTE: It's good practice to include the version without the prefixes, as to continue the sites function when the property is fully adopted.
Upvotes: 2
Reputation: 2732
Properties which are implemented based on unfinishes specs are given vendor prefix. Same thing if given vendor thinks their implementation is not finished, even though the spec is.
Upvotes: 0
Reputation: 2966
This happens because browsers do not want conflicts with each other. In addition to that, there isn't really a "spec" for box-shadow at the moment, so several browsers have their own implementation of it.
This approach allows any vendor-specific extension to coexist with any future (or current) CSS properties without causing conflicts because, according to the W3C specifications, a CSS property name will never begin with a dash or an underscore:
Source: http://reference.sitepoint.com/css/vendorspecific
Upvotes: 3