CSS Vendor prefixes (or browser prefixes) are a way for browsers to give access to new CSS features not yet considered stable.
By using prefixes, we can use these newer CSS features with the browsers that support them â instead of waiting for all browsers to catch up.
For example, before CSS Transitions were fully supported, youâd have added the prefixes, like so:
.element {
-webkit-transition: all 1s ease-out;
-moz-transition: all 1s ease-out;
-ms-transition: all 1s ease-out;
-o-transition: all 1s ease-out;
transition: all 1s ease-out;
}
The prefixes used are:
-webkit-
(Chrome, Safari, iOS Safari / iOS WebView, Android)-moz-
(Firefox)-ms-
(Edge, Internet Explorer)-o-
(Opera, Opera Mini)
Writing prefixes has traditionally been a hassle. So projects like Autoprefixer came along to automate the process, by adding any required prefixes automatically. This tool generates prefixes based on the information provided from canIuse.
Many modern frameworks (e.g. create-react-app, the Vue CLI & PostCSS) use autoprefixer out of the box, so remembering to add prefixes has become a thing of the past!
Is prefixing still necessary?
Prefixing is a rapidly declining issue.
Browsers are getting better at supporting new features. And now, the rise of experimental CSS is encouraging client-side testing of new features (via local browser settings), instead of on production websites.
If youâre working without build tools on a project that needs to function on older browsers â itâs worth running your CSS through autoprefixer. Check out the handy online tool: https://autoprefixer.github.io/. Otherwise you can rest assured that your CSS will be supported!
Related Posts:
A little about me..
Hey, Iâm Tim! đ
Iâm a freelance business owner, web developer & author. I teach both new and experienced freelancers how to build a sustainable and successful freelancing business. Check out my Complete Guide to Freelancing if you'd like to find out more.
While you're here, you can browse through my blogs where I post freelancing tips, code tutorials, design inspiration, useful tools & resources, and much more! You can also join the newsletter, or find me on X.
Thanks for reading! đ