Understanding the Differences and Usage of >>>, /deep/, ::v-deep, ::v-deep(), and :deep()

Shawn King
4 min readOct 24, 2024

In Vue projects, especially when using component-based development, there are times when you need to optimize styles within components. However, Vue’s scoped styling feature prevents external styles from directly affecting the internals of a component. To address this, the Vue community introduced deep selectors (also known as piercing or shadow-piercing selectors) that allow you to cross component boundaries and style internal elements.

Deep selectors enable you to penetrate from parent components into child components and directly modify their styles. This is particularly useful when customizing styles for third-party UI library components.

>>>

>>> is a native CSS deep selector syntax used to penetrate style encapsulation.

  • Compatibility: Only works in certain environments (like specific Webpack css-loader configurations) and native CSS. Typically requires specific configuration in Vue single-file components.
  • Note: In Vue single-file components, we usually use CSS preprocessors. However, preprocessors like Sass cannot correctly parse >>>, so it's not recommended. Instead, use /deep/ or ::v-deep, which are aliases and work correctly.
<style scoped>
.parent >>>…

--

--

Shawn King
Shawn King

Written by Shawn King

Focusing on front-end development and internet writing. Sharing technical tutorials and original fiction. https://skstory.online/

No responses yet