Home > Web Front-end > Front-end Q&A > What is the prefix usage of css3

What is the prefix usage of css3

WBOY
Release: 2022-01-24 14:26:10
Original
2188 people have browsed it

In CSS3, the prefix is ​​used to be compatible with the attribute support of different browsers. Browser manufacturers will add a private prefix in front of the attribute to support new attributes. Browsers with webkit as the core will add " -webkit-" prefix, the syntax is "-webkit-attribute:attribute value;", browsers with different kernels add different prefixes.

What is the prefix usage of css3

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

What is the usage of prefix in css3

In css, because it needs to be compatible with the attribute support of different browsers, the browser manufacturer will add a private prefix in front of the attribute to support the new attribute; the prefix is ​​"- webkit-" attributes can be used normally in browsers with webkit as the core, such as "safari" and "chrome" browsers.

1, -moz-represents the private properties of the firefox browser

2,-ms-represents the private properties of the IE browser

3,-webkit-represents the private properties of safari and chrome Attribute

4, -o- represents Opera

These are for compatibility with older versions of writing methods. Newer versions of browsers support direct writing: border-radius.

Internet Explorer 9 supports border-radius and box-shadow properties.

Firefox, Chrome and Safari support all new border properties.

For border-image: Safari 5 and older require the prefix -webkit-.

Opera supports border-radius and box-shadow properties, but the prefix -o- is required for border-image.

The example is as follows:

<html>
<head>
<style> 
div
{
width:300px;
height:100px;
background-color:#ff9900;
-moz-box-shadow: 10px 10px 5px #888888; /* 老的 Firefox */
box-shadow: 10px 10px 5px #888888;
}
</style>
</head>
<body>
<div></div>
</body>
</html>
Copy after login

Why do we need a private prefix? Because the W3C, the organization that formulates HTML and CSS standards, is very slow. Usually, a member of the w3c organization proposes a new attribute, such as rounded border-radius, and everyone thinks it is good, but w3c will not set a standard for this attribute, but will go through a very complicated process and go through a lot of reviews.

Browser vendors are not willing to wait that long. If they feel that an attribute is mature enough, they will add support to the browser. But to avoid changes when w3c announces the standard in the future, a private prefix will be added, such as -webkit-border-radius, to support new attributes in advance. When w3c announces the standard in the future, the standard writing method of border-radius is established. , and let the new version of the browser support the border-radius writing method.

For example, Chrome 10 does not recognize border-radius and can only use webkit-border-radius, but Chrome 12 can recognize it. So when writing CSS, writing like this can ensure that both Chrome10 and Chrome12 can display correctly when browsing web pages.

Currently there are many private prefixes that can no longer be written, but in order to be compatible with older versions of browsers, private prefixes and standard methods can still be used, and the transition will be gradual

(Learning video sharing: css video tutorial)

The above is the detailed content of What is the prefix usage of css3. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template