Overview
The Custom CSS Extension allows you to add custom CSS styles to any WordPress block directly in the editor. Perfect for advanced users who need precise styling control, unique designs, or custom animations without creating child themes or custom plugins.

Key Features
- Block-Specific CSS: Add CSS that only affects the selected block
- Syntax Highlighting: Code editor with syntax highlighting
- Auto-completion: Intelligent CSS property suggestions
- Error Validation: Real-time CSS syntax checking
- Scoped Styles: Automatically scoped to prevent conflicts
- Supports Pseudo-classes: Use :hover, :focus, ::before, ::after
- Media Queries: Add responsive custom styles
How to Use
- Select any block in the editor
- Navigate to the Advanced tab in block settings
- Find the Custom CSS section
- Write your CSS (automatically scoped to the block)
- Preview changes in the editor
- Save and view on frontend
CSS Editor Features
Automatic Scoping
Your CSS is automatically scoped to the block using its unique ID. You can reference the current block with the & symbol (like in SCSS).
Example CSS
/* Style the block */
& {
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
/* Hover effects */
&:hover {
transform: translateY(-5px);
transition: transform 0.3s ease;
}
/* Style child elements */
& .wp-block-button {
margin-top: 20px;
}
/* Responsive styles */
@media (max-width: 768px) {
& {
padding: 10px;
}
}
Common Use Cases
- Custom Animations: Add unique CSS animations and transitions
- Advanced Hover Effects: Complex hover states and interactions
- Custom Shapes: Clip-path and shape styling
- Gradient Effects: Complex gradient backgrounds
- Typography Fine-tuning: Precise font adjustments
- Shadow Effects: Custom box and text shadows
- Grid Layouts: Advanced CSS Grid implementations
- Pseudo-elements: Add ::before/::after decorative elements
Best Practices
- Use the & symbol to reference the current block
- Keep CSS organized with comments
- Test styles on multiple browsers
- Avoid !important unless absolutely necessary
- Use CSS custom properties for reusable values
- Validate CSS syntax before saving
- Document complex styles with comments
- Consider performance impact of complex animations
Advanced Techniques
CSS Variables
& {
--primary-color: #007cba;
--spacing: 20px;
color: var(--primary-color);
padding: var(--spacing);
}
Complex Animations
@keyframes slideIn {
from { opacity: 0; transform: translateX(-20px); }
to { opacity: 1; transform: translateX(0); }
}
& {
animation: slideIn 0.5s ease-out;
}
Pseudo-elements
&::before {
content: ;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(to right, #007cba, #00a0d2);
}
Troubleshooting
- Styles not applying: Check CSS syntax, ensure proper scoping with &
- Conflicts with theme: Increase specificity or use !important sparingly
- Editor vs Frontend differences: Some editor styles may differ, always test frontend
- Syntax errors: Use the built-in validator to identify issues
Security Note
Custom CSS is sanitized and validated to prevent XSS attacks. Only CSS is allowed – JavaScript and external resources are automatically removed.