Usage of symbol '>' in CSS Selector

Confused about the '>' symbol in CSS? This powerful selector targets direct child elements only, giving you precise control over your styles. It’s perfect when you want to avoid affecting nested elements deeper in the hierarchy.

That means the selector div > p.some_class only selects paragraphs of .some_class that sit directly inside a div, not paragraphs that are nested further within.

CSS

 div > p.some_class {css rules} 

HTML

<div>
<p class="some_class">Some text here</p>
<!-- Selected [1] -->
<blockquote>
<p class="some_class">More text here</p>
<!-- Not selected [2] --></blockquote>
</div>

What's selected and what's not:

Selected
This p.some_class is located directly inside the div, hence a parent-child relationship is established between both elements.

Not selected
This p.some_class is contained by a blockquote within the div, rather than the div itself. Although this p.some_class is a descendant of the div, it's not a child; it's a grandchild.

Consequently, while div > p.some_class won't match this element, div p.some_class will, using the descendant combinator instead.

Related Articles

Boki

Boki

With more than 15 years of hands-on experience in Joomla, the author specializes in building and redesigning websites that are both functional and easy to use. Driven by a passion for clean code and thoughtful design, they help individuals and businesses bring their digital ideas to life—turning concepts into smooth, engaging online experiences.

About

Saint Art Designs is a freelance Joomla web developer specializing in modern, responsive, and secure websites.

  • Joomla Web Development Service
  • Joomla Web Design
  • Joomla Upgrade
  • Joomla SEO

Why Hire Me?

With over two decades of experience in Joomla development, I deliver high-quality, stable, and scalable websites.

Each project is approached with precision, clear communication, and a focus on long-term value.

Get a Quote

Online Profiles

Freelancer
Upwork
Linkedin
Facebook
Google Review

Contact Info