Skip to content
The Admin Bar
  • Get Involved
    • Facebook Group
    • Barfly Community
    • TABLE Mastermind
  • Learn
    • Articles
    • Events
    • Newsletter
    • YouTube
    • WordPress Professionals Survey
    • SEO Weekly
    • Security Weekly
    • Accessibility Weekly
  • Products
  • About
  • Free Stuff

Understanding Compound Selectors in GenerateBlocks

I recently received an email from a GenerateBlocks user who was confused about the compound selector toggle in the GenerateBlocks system. If you’re not used to writing CSS, this toggle might seem a bit …

Kyle Van Deusen

Kyle Van Deusen

Published:

February 17, 2025

Filed Under:

General

Kyle Van Deusen

Kyle Van Deusen

The Admin Bar

After spending 15 years as a graphic designer and earning a business degree, I launched my agency, OGAL Web Design, in 2017. A year later, after finding the amazing community around WordPress, I co-found The Admin Bar, which has grown to become the #1 community for WordPress professionals. I'm a husband and proud father of three, and a resident of the Commonwealth of Virginia.

Compound selectors
This content contains affiliate links. View our affiliate disclaimer.

I recently received an email from a GenerateBlocks user who was confused about the compound selector toggle in the GenerateBlocks system. If you’re not used to writing CSS, this toggle might seem a bit mysterious. So, I thought I’d create a quick guide to explain when and why you might want to use this toggle—and when you don’t.

YouTube video

What Is a Compound Selector?

In GenerateBlocks, the compound selector toggle is a helper tool that adds an ampersand (&) to your selector. The ampersand acts as a placeholder for the class name you’re working with, allowing you to create more specific selectors without manually typing the class name.

When the toggle is off, the selector you create will include a space, which targets descendant elements. When the toggle is on, the ampersand replaces the space, allowing you to target pseudo-classes (like :hover) or create more complex selectors.

Setting Up the Example

To demonstrate how compound selectors work, I’ve set up a simple page with three identical sections:

  1. Each section contains a container with an inner container that constrains the content width.
  2. Inside each inner container is a paragraph block.

We’ll use this setup to explore how compound selectors work and when to use them.

Using a Basic Class

Let’s start by adding a class to the first inner container.

  1. Add a Class:
    • Select the inner container and give it a class name (e.g., kvd-wrapper).
    • Start with a blank style.
  2. Apply a Background Color:
    • Go to the Background settings and set the background color to blue.
  3. Reuse the Class:
    • Add the same kvd-wrapper class to the third section.
    • Both sections now share the same background color.

If you update the background color in the kvd-wrapper class (e.g., change it to yellow), the change will apply to all sections using that class.

Descendant Selectors

Now let’s target the paragraphs inside the kvd-wrapper class.

  1. Create a Descendant Selector:
    • Select the kvd-wrapper class and click More > New.
    • Turn off the compound selector toggle.
    • Type p (for paragraph) and hit Create.
  2. Resulting Selector:
    • The selector will look like this: .kvd-wrapper p.
    • This is a descendant selector, meaning it targets all paragraphs inside the kvd-wrapper class.
  3. Apply a Style:
    • Change the text color to light gray.
    • Only the paragraphs inside the kvd-wrapper sections will update, while the middle section remains unchanged.

If you add the kvd-wrapper class to the middle section, its paragraph will also inherit the light gray text color.

Using Compound Selectors

Now let’s use the compound selector toggle to create a hover effect.

  1. Create a Hover Selector:
    • Select the kvd-wrapper class and click More > New.
    • Turn on the compound selector toggle.
    • Type :hover (no space) and hit Create.
  2. Resulting Selector:
    • The selector will look like this: .kvd-wrapper:hover.
    • This targets the kvd-wrapper container when it’s hovered.
  3. Apply a Style:
    • Change the background color to blue.
    • Now, when you hover over the kvd-wrapper sections, the background color changes to blue.

Combining Compound and Descendant Selectors

Let’s take it a step further by combining a hover effect with a descendant selector.

  1. Create a Combined Selector:
    • Select the kvd-wrapper class and click More > New.
    • Turn on the compound selector toggle and type :hover.
    • Add a space and type p (for paragraph).
  2. Resulting Selector:
    • The selector will look like this: .kvd-wrapper:hover p.
    • This targets paragraphs inside the kvd-wrapper container when the container is hovered.
  3. Apply a Style:
    • Change the text color to yellow.
    • Now, when you hover over the kvd-wrapper sections, the background changes to blue, and the text changes to yellow.

Key Differences Between Compound and Descendant Selectors

  • Compound Selector (Toggle On):
    • Adds an ampersand (&) to the selector.
    • Targets pseudo-classes (e.g., :hover) or creates more specific selectors without spaces.
  • Descendant Selector (Toggle Off):
    • Includes a space between the class name and the target element.
    • Targets child elements inside the container.

Practical Use Cases

When to Use Compound Selectors

  • Pseudo-Classes:
    • Use compound selectors for hover effects, focus states, or other pseudo-classes (e.g., .kvd-wrapper:hover).
  • Sibling or Direct Child Selectors:
    • Use compound selectors for more specific targeting (e.g., .kvd-wrapper > p).

When to Use Descendant Selectors

  • Child Elements:
    • Use descendant selectors to target elements inside a container (e.g., .kvd-wrapper p).

Understanding the Toggle

The simplest way to think about the toggle is:

  • Toggle Off: Adds a space between the class name and the target element.
  • Toggle On: Adds an ampersand (&) and removes the space, allowing for pseudo-classes or more specific selectors.

Learning More

To fully understand when to use compound selectors versus descendant selectors, it’s helpful to learn more about CSS selectors. I’ll include links to resources that explain these concepts in greater detail.

Wrapping Up

The compound selector toggle in GenerateBlocks is a powerful tool, but it requires a basic understanding of CSS to use effectively. Once you grasp the difference between compound and descendant selectors, you’ll be able to create more advanced styles and interactions in your designs.

This tutorial is just scratching the surface of what’s possible with GenerateBlocks’ selector system. I’ll be covering more advanced use cases in upcoming posts, so stay tuned!

Share This Article!
FacebookXLinkedInEmail
Kyle Van Deusen

Kyle Van Deusen

The Admin Bar

After spending 15 years as a graphic designer and earning a business degree, I launched my agency, OGAL Web Design, in 2017. A year later, after finding the amazing community around WordPress, I co-found The Admin Bar, which has grown to become the #1 community for WordPress professionals. I'm a husband and proud father of three, and a resident of the Commonwealth of Virginia.

Come Join Us!

Join the #1 WordPress Community and dive into conversations covering every aspect of running an agency!

Join Group

Kyle Van Deusen

Community Manager

Latest Events

September 16, 2025

Termageddon 2.0

Better Tools, Smoother Workflows, Happier Clients

August 19th, 2025

Which WordPress Page Builder is the Most Accessible?

The 2025 Page Builder Accessibility Report

August 15, 2025

Managing Your Agency with Moxie

Can this all-in-one solution help you streamline your agency and calm the chaos?
Care Plan Toolkit

Save time, boost profits, and confidently manage client websites with proven tools, tips, and resources.

Download Free
Bento Toolkit
The Friday Chaser

Wash down the week with the best of The Admin Bar! News, tips, and the best conversations delivered straight to your inbox every Friday!

Subscribe Today

More Articles

Wordpress admin plugins plugin activated
September 23, 2025

A Beginner’s Guide to Functionality Plugins in WordPress

Learn how to turn your custom code snippets into a clean, reusable WordPress functionality plugin that’s safe, organized, and future-proof.

Barfly profile elsie gilmore
September 22, 2025

Member Profile: Elsie Gilmore

Elsie Gilmore has been at this game for over two decades — long before WordPress was …

Barfly profile bj bowen
September 15, 2025

Member Profile: BJ Bowen

BJ Bowen’s path into web design and SEO has been anything but linear. From her early …

2025phone

Join the #1 WordPress Community

The Admin Bar community is at the heart of what we do. Join in on the daily conversation and get involved.

Request Membership
The Admin Bar logo.

Explore

Community

Events

Articles

Products

Newsletter

Agency Report Card

Care Plan Toolkit

Noted!

Barfly Login

Policies

Privacy Policy

Terms of Service

Affiliate Agreement

Affiliate Disclaimer

Accessibility Statement

Privacy Settings

Misc.

Advertise

Login

Contact

© 2017-2025 The Admin Bar (a Division of OGAL Web Design) — All Rights Reserved

The Admin Bar logo.
  • Get Involved
    • Facebook Group
    • Barfly Community
    • TABLE Mastermind
  • Learn
    • Articles
    • Events
    • Newsletter
    • YouTube
    • WordPress Professionals Survey
    • SEO Weekly
    • Security Weekly
    • Accessibility Weekly
  • Products
  • About
  • Free Stuff
YouTube Facebook
Sell More Care Plans
Care Plan Toolkit

Save time, boost profits, and confidently manage client websites with proven tools, tips, and resources.

Download Free
Bento Toolkit