Home > Web Front-end > CSS Tutorial > How to Order Vendor-Specific and W3C CSS Declarations?

How to Order Vendor-Specific and W3C CSS Declarations?

Susan Sarandon
Release: 2024-11-15 15:20:03
Original
1000 people have browsed it

How to Order Vendor-Specific and W3C CSS Declarations?

Vendor-Specific CSS Declaration Ordering

When using vendor-specific CSS declarations, it becomes necessary to consider their ordering. While it's known that the -webkit- and -moz- prefixes don't affect the order of application, questions arise about the best practices for ordering W3C standard and vendor-specific versions.

The recommended approach is to place the unprefixed, W3C standard property last in the declaration block:

.foo {
    -moz-border-radius: 10px;    /* Mozilla */
    -webkit-border-radius: 10px; /* Webkit */
    border-radius: 10px;         /* W3C */
}
Copy after login

This helps ensure that the browser will prioritize the use of the W3C standard implementation.

Why is this preferred? Firstly, the -webkit-border-radius prefix indicates an experimental property that may deviate from the specification. In comparison, border-radius should adhere to the specifications strictly.

By placing the W3C implementation last, browsers that support it will use it, promoting consistency among browsers. This approach provides a future-proof solution as CSS evolves and browser support for the standard increases.

The above is the detailed content of How to Order Vendor-Specific and W3C CSS Declarations?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template