CSS3 Instance Resolution: The difference between a colon before a pseudo class and a two colon

Source: Internet
Author: User

Web page Production WEBJX article introduction: in a project, once to use:: Selection pseudo element, and then the development classmate asked me, CSS in a colon and two colon god horse difference?

In a project, once to use:: Selection pseudo element, and then the development classmate asked me, CSS in a colon and two colon god horse difference?

This seems to be really a problem, perhaps a lot of front-end students have doubts about it, looked up some data to confirm the difference between the next two symbols, in short: single colon (:) for CSS3 pseudo class, double colon (::) used to CSS3 pseudo element .

There is a description in the specification of the CSS3 selector for the consortium :

A Pseudo-element is made of two colons (::) followed by the name of the pseudo-element. This:: Notation are introduced by the current document in order to establish a discrimination between pseudo-classes and P Seudo-elements. For compatibility with existing style sheets, user agents must also accept the previous One-colon notation for Pseudo-elem Ents introduced in CSS levels 1 and 2 (namely,: First-line,: First-letter,: Before And:after). This compatibility isn't allowed for the new pseudo-elements introduced at CSS Level 3.

Simply translated, the effect is that pseudo elements consist of double colons and pseudo element names. Double colons are introduced in the current specification to differentiate between pseudo classes and pseudo elements. However, the pseudo class compatible with existing styles, browsers need to support the old pseudo class, such as: First-line,: First-letter,: Before, after and so on.

So now you can fully answer the question in the title, for CSS2 before the pseudo elements, such as: before, single colon and double colon:: Before function is the same .

So, if your site only needs to be compatible with WebKit, Firefox, Opera and other browsers, it is recommended to use double colon for pseudo elements, if you have to be compatible with IE browser, or use CSS2 single colon to be more secure.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.