Unlock Hidden Power: 6 Little-Known Ways to Master Custom Block Styles in WordPress
” data-medium-file=”https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=300″ data-large-file=”https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=1024″ loading=”lazy” width=”1024″ height=”482″ src=”https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=1024″ alt=”A purple border style selected in the Styles panel and the purple border showing on the image in the WordPress editor” class=”wp-image-79433″ srcset=”https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=1024 1024w, https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=150 150w, https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=300 300w, https://en-blog.files.wordpress.com/2025/05/purple-border.jpg?w=768 768w, https://en-blog.files.wordpress.com/2025/05/purple-border.jpg 1064w” sizes=”(max-width: 1024px) 100vw, 1024px”>
Note: There is also a bug report open about the stylesheet loading even when the block styles aren’t used. Because of this, it’s not recommended for complex CSS.
Method 4: register block styles using JavaScript + CSS
- Best for: Plugin developers and theme developers
- Where you would typically use it: In a separate
*.js
file, enqueued in a plugin file, or infunctions.php
- Version requirements: WordPress 5 or higher
Compared to using the separate JSON file to add a block style variation, using JavaScript is more elaborate. It has three parts: