What does the '::' selector mean in CSS

2020-04-27 03:58发布

I came across a blog-post, where :: was used in their CSS code.

Here is part of their code:

::-webkit-scrollbar {
  width: 10px;
}

The code is working fine for the scrollbar, but I could not find where this selector is defined. What does this officially mean

1条回答
【Aperson】
2楼-- · 2020-04-27 04:38

:: signifies a pseudo-element, as opposed to a pseudo-class :. Pre-CSS3 they both used : and support is a little scrappy for the :: syntax still.

A pseudo-class filters existing elements.

a:link means all <a>s that are :link.

A pseudo-element is a new fake element. div::after create a "fake" element with <div> but after its content.

References

查看更多
登录 后发表回答