3 ms·
How could one differentiate between different implementations in browsers? Prefixes help. My favorite example is CSS gradients with transparency. Mozilla: ba
by Permit 14y ago
How could one differentiate between different implementations in browsers?
Prefixes help. My favorite example is CSS gradients with transparency.
Mozilla:
background-image: -moz-linear-gradient(
rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0) 95%
);
IE 9:
filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr=#550000FF, endColorstr=#550000FF
);
IE 8:
-ms-filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr=#550000FF, endColorstr=#550000FF
);
Webkit:
background-image: -webkit-gradient(
linear, left top, left bottom, from(rgba(50,50,50,0.8)),
to(rgba(80,80,80,0.2)), color-stop(.5,#333333)
);
How would one properly differentiate between browsers implementing functionality differently in this case without prefixes? The only option would be to wait years for standards to be finalized and then implemented.
- TazeTSchnitzel 14y agoWell, each of those values will only work correctly in one browser, other browsers would skip the ones they don't understand, yes?
- emil0r 14y agoNow the client wonders why the website looks so different in different browsers.
- TazeTSchnitzel 14y agoEh? Did you even read what I posted? Browsers ignore CSS they don't understand, hence you can put several versions of a rule, and a browser will use the one it understands.
- jonathanyc 14y agoHow is the browser supposed to magically discern developer intent?
- TazeTSchnitzel 14y agoWhat do you mean? Competing syntaxes usually don't get confused by browsers as being valid.
- Permit 14y agoBecause of the prefixes, yes the browser knows which properties to skip. But you were advocating removing prefixes, so I'm wondering how browser are supposed to differentiate between properties?
- TazeTSchnitzel 14y agoEh? Have you ever done, say... color: rgb(255, 255, 255); color: rgba(255, 255, 255, 0.5); Browser which do not support rgba simply ignore it and use the rgb() value.
- Permit 14y agoWait so you want them all to use the same prefix? So you'd have five properties called "filter:" or "background-image:"? If my gradient looked bad in Mozilla, how on earth would the I know which property to change? They'd seem identical unless I memorized every single browser specific implementation of every CSS property.
- TazeTSchnitzel 14y agoComments exist, you know. It's not like we don't have this issue already with different versions of the same engine changing syntax.
- Permit 14y agoCode should be self-documeting. You're proposing we remove something that serves to differentiate between properties in favor of simply adding the exact same information in the form of a comment.
- TazeTSchnitzel 14y agoOnly where necessary. Where browsers do not disagree, it saves developers time and effort.