How to Use -webkit-, -moz- and -ms- Prefixes in CSS
The -webkit-, -moz- and -ms- prefixes are CSS vendor prefixes, not browser extensions: you add them to the front of a CSS property so a specific browser engine reads it. Write the prefixed versions first and the standard, unprefixed property last. Today you need prefixes only for a short list of properties, depending on which browsers your visitors use.
The prefixes map to engines. -webkit- covers Safari and Chromium-based browsers such as Chrome, the current Microsoft Edge and Opera. -moz- covers Firefox. -ms- covers Internet Explorer and the older, pre-Chromium version of Edge. You may also see -o-, which targeted the old Opera engine before Opera moved to Chromium.
What is the primary purpose of using vendor prefixes in CSS?
A vendor prefix lets a browser maker ship an experimental or unfinished CSS feature without claiming it matches the final standard. A vendor prefix is a short label, such as -webkit-, placed before a property name so only that vendor’s engine applies it. If the specification changed later, the prefixed version could keep its old behavior while the unprefixed property followed the finished rules.
Think of it like a “beta” sticker on a product. Developers could try the feature in one browser, knowing it might change. The downside was that sites started relying on beta features, so browsers ended up supporting each other’s prefixes to avoid breaking pages. For that reason, browser makers now usually test new features behind settings flags instead of prefixes.
How to write vendor-prefixed CSS, step by step
Writing vendor-prefixed CSS comes down to listing every needed version of a property inside the same rule, with the standard one at the bottom. Browsers ignore lines they do not understand and apply the last valid line they do, so the order matters.
- Write the standard property first in your head. Start from the unprefixed property you actually want, for example user-select: none;.
- Check whether it still needs a prefix. Look the property up in a browser compatibility table, such as the one on MDN Web Docs or Can I Use, and see which browser versions require a prefix.
- Add only the prefixes your audience needs. For the example above, add -webkit-user-select: none; for Safari. Skip -ms- unless you still support Internet Explorer.
- Put the prefixed lines above the standard line. The final block reads -webkit-user-select: none; and then user-select: none;. When a browser supports both, the standard version wins because it comes last.
- Prefix values and at-rules too, when required. Some prefixes go on values (display: -webkit-box;) or at-rules (@-webkit-keyframes), not just on property names.
- Test in each target browser. Open the page in Chrome, Safari, Firefox and Edge, and use each browser’s developer tools to see whether a line is crossed out as invalid.
Let a tool add prefixes for you
Autoprefixer is the standard way to handle vendor prefixes in modern projects: you write plain CSS, and the tool adds only the prefixes your chosen browsers need. Autoprefixer is a PostCSS plugin that reads browser support data and a “browserslist” setting that describes the browsers you support.
- Set your browser targets. A browserslist entry in your project config tells the tool which browsers and versions matter to you.
- Run it in your build. Most build tools, including Vite and webpack setups, can run PostCSS with Autoprefixer automatically.
- Delete hand-written prefixes. Old copied prefixes can override newer behavior or clutter the file. Autoprefixer can also remove outdated ones.
Copying CSS snippets from old tutorials is a common way prefixes pile up. If a snippet includes -ms-filter or -moz-border-radius, those lines target browsers that are long out of date and can be removed.
Is WebKit still needed?
Yes, the WebKit engine is still needed because Apple’s Safari runs on it, but most -webkit- prefixes are no longer needed for everyday CSS. WebKit is the browser engine behind Safari on Mac, iPhone and iPad. Chrome and the current Edge use Blink, an engine that began as a fork of WebKit, which is why they still understand many -webkit- properties.
A handful of -webkit- properties remain in regular use because they never got a fully supported standard version or because Safari still needs them. Examples include -webkit-line-clamp for cutting text off after a set number of lines, -webkit-text-stroke for outlined text, and -webkit-background-clip: text for gradient-filled text. Firefox also accepts several of these -webkit- names so that sites built for Chrome and Safari display correctly.
| Prefix | Engine | Browsers | Still worth adding? |
|---|---|---|---|
| -webkit- | WebKit / Blink | Safari, Chrome, current Edge, Opera | Sometimes, for specific properties |
| -moz- | Gecko | Firefox | Rarely |
| -ms- | Trident / EdgeHTML | Internet Explorer, legacy Edge | Only if you still support those browsers |
| -o- | Presto | Old Opera | No |
CSS works in Chrome but not in Edge or Safari: how to fix it
When CSS works in Chrome but not in another browser, a missing prefix or an unsupported property is one likely cause. The quickest fix is to look the property up in a compatibility table and add the prefix or fallback that browser needs. Check these causes in order:
- Old Edge version. The legacy, pre-Chromium Edge reads -ms- prefixes, not -webkit-. The current Edge reads the same CSS as Chrome, so updating Edge often resolves the difference.
- Safari needs a -webkit- version. Safari can lag behind Chrome on some features and may only support the prefixed name.
- Wrong order. A prefixed line placed after the standard line can override the finished behavior.
- The feature is simply unsupported. No prefix helps if the browser has not implemented the feature; use a fallback or an @supports check.
| Symptom | Likely cause | Fix |
|---|---|---|
| Style works in Chrome, ignored in Safari | Safari needs the -webkit- version | Add the -webkit- line above the standard one |
| Style works in Chrome, broken in Edge | Legacy Edge or an outdated Edge build | Update Edge; add -ms- only if you support legacy Edge |
| Property crossed out in developer tools | Misspelled or unsupported property | Check spelling and the compatibility table |
| Animation runs in one browser only | Keyframes defined only with one prefix | Define standard @keyframes, plus prefixed ones if needed |
To guard against an unsupported feature, wrap the newer style in an @supports rule and keep a simpler style outside it. Browsers that pass the test get the new look; others get the fallback.
How to use a Chrome browser extension
If you were looking for actual browser extensions rather than CSS prefixes, Chrome extensions are installed from the Chrome Web Store. Open the store, find the extension, click Add to Chrome, and confirm the permissions prompt. The extension then appears under the puzzle-piece icon next to the address bar, where you can pin it to the toolbar.
Before installing, read the permissions the extension asks for and install only from developers you trust, since extensions can read data on the pages you visit. Microsoft Edge can also install many Chrome extensions because both browsers share the Chromium base. Apple, Google, Microsoft and Mozilla formed the WebExtensions Community Group at the W3C to work toward a common extension model across their browsers.
FAQ
– Do I still need -ms- prefixes?
No, -ms- prefixes are needed only if you still support Internet Explorer or the legacy version of Microsoft Edge. The current Edge is built on Chromium and reads standard and -webkit- CSS like Chrome. Most modern sites can drop -ms- lines entirely.
– Does the order of prefixed properties matter?
Yes, the standard unprefixed property should always come last. Browsers apply the last valid declaration they understand, so placing the standard line at the end makes sure supporting browsers use the finished version of the feature.
– Which browser is considered the worst for privacy?
No single browser is the worst for privacy in every case, because protection depends heavily on settings, sign-in choices and installed extensions. Firefox, Safari and Brave include built-in tracker blocking, while any browser becomes less private with risky extensions installed. Review privacy settings and extension permissions in whichever browser you use.
– Can vendor prefixes break my site?
Vendor prefixes rarely break a site, but outdated ones can cause inconsistent styling when a prefixed version behaves differently from the standard property. Keeping prefixes current with a tool like Autoprefixer, and always ending with the standard property, avoids most of these problems.
