Should I use single colons (:) or double colons (::) for before, after, first-letter and first-line pseudo-elements?

前端 未结 3 1566
春和景丽
春和景丽 2020-11-29 06:08

From MDN:

The :: notation was introduced in CSS 3 in order to establish a discrimination between pseudo-classes and pseudo-elements. Br

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 06:32

    As I mentioned in this comment previously - http://css-tricks.com/html5-progress-element/#comment-533395

    Short Answer – Use single colon notation :

    Long Answer – There’s no real difference between :before and ::before, or between :after and ::after. But since the older browsers use a single colon notation, so using : is always a safer bet. Read this spec defined by W3C on pseudo elements which states that,

    This :: notation is introduced by the current document in order to establish a discrimination between pseudo-classes and pseudo-elements. For compatibility with existing style sheets, user agents must also accept the previous one-colon notation for pseudo-elements introduced in CSS levels 1 and 2 (namely, :first-line, :first-letter, :before and :after). This compatibility is not allowed for the new pseudo-elements introduced in CSS level 3.

提交回复
热议问题