- Root - The block’s primary CSS selector
- Feature - Selectors for block supports (color, typography, etc.)
- Subfeature - Selectors for individual style properties
Root selector
The root selector is the block’s primary CSS selector. If not specified, it defaults to.wp-block-<name>.
For layout to work correctly, the block should have a classname that matches its selector.
Feature selectors
Feature selectors apply styles for specific block supports (border, color, typography, etc.) to different elements.Example: Different elements for color and typography
- Color styles to
.my-custom-block - Typography styles to
.my-custom-block > h2
Subfeature selectors
Subfeature selectors target individual style properties within a feature.Example: Typography with different selectors
- Most typography styles to
.my-custom-block > h2 - Text decoration to
.my-custom-block > h2 span
Shorthand syntax
Instead of using an object with aroot key, use a string for simpler feature selectors:
Fallback behavior
Selectors fall back in this order:- Subfeature selector
- Feature root selector
- Block root selector
Example with fallbacks
color.textto.my-custom-block p(explicit subfeature selector)color.backgroundto.my-custom-block(falls back to root)typography.fontSizeto.my-custom-block > h2(falls back to feature root)typography.text-decorationto.my-custom-block > h2 span(explicit subfeature)
Custom CSS selector
Thecss selector controls which selector is used for custom CSS rules from theme.json’s styles.blocks.<block-type>.css.
As a string
As an object
Available features
Feature selectors can be defined for:bordercolordimensionsfiltershadowspacingtypography
Complete example
Use cases
Applying typography to inner heading
Separating background and text colors
Fine-grained spacing control
Best practices
- Use descriptive class names for custom selectors
- Ensure selectors match the actual block HTML structure
- Keep selectors specific enough to avoid conflicts
- Test selectors with theme.json Global Styles
- Document custom selectors for theme developers