DEV Community

Nesha Zoric
Nesha Zoric

Posted on

How to Make All Browsers Understand Your CSS

Have you ever wondered about what -moz- or -webkit- markings in CSS mean? Well, if you have, you are in the right place! Those markings are called vendor prefixes.

About Vendor Prefixes

Let’s answer the question: What are vendor prefixes? Simply put, vendor prefixes are a way for your browser to support new CSS features before they become fully supported in all browsers.

When CSS3 became popular, all sorts of new features started appearing. Unfortunately, not all of them were supported across all browsers. Vendor prefixes helped developers use those new features, and have them supported instantly without having to wait for each of them to become available for every browser.

Vendor prefixes are not a hack, and you should feel free to use them.

A good way to check which property is available to use without a vendor prefix is by checking the CanIUse service. There you can see which browser currently supports which property.

The Prefixes

Major browsers use the following prefixes:

  • -webkit- Chrome, Safari, newer versions of Opera, almost all iOS browsers,
  • -moz- Firefox,
  • -o- Old versions of Opera,
  • -ms- Microsoft Edge and Internet Explorer.

When using vendor prefixes, keep in mind that they are only temporary. A lot of properties that needed to have vendor prefixes attached to them are now fully supported and don’t need them.

How Should You Use Them?

You can easily use vendor prefixes, simply by adding them before the property, like this:

.element {
  -webkit-transform: rotate(60deg);
  -ms-transform: rotate(60deg);
  -o-transform: rotate(60deg);
  transform: rotate(60deg);
}

In this case, you ensure the property is supported in browsers.

It is a good practice to put the unprefixed property at the bottom. This way, by using the cascading nature of CSS, you ensure that when the property is fully supported, this is the one it will use.

Which Property Needs Prefixing?

This is a frequently asked question. A good thing would be to stop guessing and check out these websites:

Tired of Writing Prefixes?

If you are tired of writing prefixes every time you need one, there are a couple of autoprefix services that can help you:

Conclusion

Hopefully, this short introduction to vendor prefixes helped you to understand them more, and fear them less. Make sure to use them correctly in your new projects, and remember: vendor prefixes are our friends!

If you need a help including a bit of CSS in your project don't hesitate to reach out to our team. We'll gladly give you a hand! :)

Top comments (6)

Collapse
 
jibinp profile image
Jibin Philipose

Thank you, this is so helpful.

Collapse
 
sethusenthil profile image
Sethu Senthil

Are there any auto prefixers for vs code?

Collapse
 
imichall profile image
imichall • Edited

Yeah, there is an extension for it.
marketplace.visualstudio.com/items...

Collapse
 
iamtahazzot profile image
Tahazzot

Is this extension perfect? (I don't think so)

Collapse
 
patrickcole profile image
Patrick Cole

👍 +1 on Autoprefixer

Collapse
 
sahilatahar profile image
Sahil Atahar

Thanks a lot