You probably don’t know how to add custom CSS to Gutenberg Blocks. Don’t worry! You are not alone!
As most WordPress users are familiar with the Classic Editor, using Gutenberg, especially for something a little more technical, like adding custom CSS to a Gutenberg block, seems complicated.
But the good news is that adding custom CSS to a Gutenberg block is as easy as pouring water into a glass. YES! You heard it right.
In this WordPress Gutenberg editor tutorial, we walk you through step-by-step instructions on how to add custom CSS to Gutenberg Blocks in two simple ways.
Ready? Let’s dive right in!
Method #1: Add Custom CSS to Gutenberg Blocks via WordPress Theme Customizer
If you are new to Gutenberg Editor, you might be thinking that there is no way to add custom CSS. In reality, this is not the case. In fact, adding custom CSS to Gutenberg blocks via the WordPress Theme Customizer is simpler than you might think.
To add custom CSS to Gutenberg Blocks, follow the steps below:
- First, select the post or page on which you want to add custom CSS to Gutenberg Blocks, then click to edit it.
![Edit WordPress Page Edit WordPress Page](https://wpdesc.com/wp-content/uploads/2024/06/edit-wordpress-page-1024x217.png)
- Once the editing window opens, choose the specific block you wish to edit.
- Now, open the settings sidebar by either using the shortcut key Ctrl + Shift + , or clicking the Settings icon (which looks like a square with two uneven columns ) in the top right corner.
- In the settings sidebar, navigate to the ‘Block’ section and locate ‘Advanced’ → ‘Additional CSS Class(es).’
- In the field labeled ‘Additional CSS Class(es),’ type in the name of your desired custom class name, e.g., my-custom-block.
![Additional CSS Class in Gutenberg Additional CSS Class in Gutenberg](https://wpdesc.com/wp-content/uploads/2024/06/additional-css-class-in-gutenberg-1024x462.png)
- After entering the CSS style name, select ‘Preview’ to fully add the custom CSS to your Gutenberg block.
- On the preview window, click the ‘customize’ button on the top panel of the screen.
![Customize Option to Access WordPress Theme Customizer Customize Option to Access WordPress Theme Customizer](https://wpdesc.com/wp-content/uploads/2024/06/customize-option-to-access-wordpress-theme-customizer-1024x123.png)
- On the preview window, click the ‘customize’ button on the top panel of the screen.
- Once in the customization panel, find the ‘Additional CSS’ option from the right-hand menu and click on it. You’ll see a box where you can add your custom CSS.
- Now, you can add custom CSS code to the box, but make sure the first line of the code is the name of the custom CSS style you entered earlier (i.e., ‘my-custom-block’)
![Additional CSS Option in WordPress Theme Customizer Additional CSS Option in WordPress Theme Customizer](https://wpdesc.com/wp-content/uploads/2024/06/additional-css-option-in-wordpress-theme-customizer-1024x414.png)
- After successfully adding the custom CSS code, simply hit the ‘Update’ button.
Now, go back to that particular page or post, and you’ll see the changes you just made by adding the custom CSS code.
In our example, we have changed the color of the initial paragraph of the Sample Page to red, which you can see in the screenshot below.
![Change of Color After Adding Custom CSS Change of Color After Adding Custom CSS](https://wpdesc.com/wp-content/uploads/2024/06/change-of-color-after-adding-custom-css-1024x474.png)
If you want to use the site editor to add custom CSS to Gutenberg blocks, follow the steps below:
- After clicking the ‘customize’ button, simply select the ‘Use Site Editor’ option.
![Use Site Editor Option in WordPress Theme Customizer Use Site Editor Option in WordPress Theme Customizer](https://wpdesc.com/wp-content/uploads/2024/06/use-site-editor-option-in-wordpress-theme-customizer-1024x364.png)
- Next, go to ‘Navigation’ → ‘Sample Page’ (your desired page or post).
- Click on the ‘three-dot’ to open the menu and then select ‘Go to Sample Page.’
![Navigate WordPress Page in WordPress Site Editor Navigate WordPress Page in WordPress Site Editor](https://wpdesc.com/wp-content/uploads/2024/06/navigate-wordpress-page-in-wordpress-site-editor-1024x397.png)
- Now, click on the edit icon next to ‘Sample Page’ (or your desired page or post).
![Edit WordPress Page in WordPress Site Editor Edit WordPress Page in WordPress Site Editor](https://wpdesc.com/wp-content/uploads/2024/06/edit-wordpress-page-in-wordpress-site-editor-1024x397.png)
- Once you are on the page, click on the ‘Style’ icon at the top left corner, select the ‘three dots’ option, and click ‘Additional CSS’ from the drop-down menu.
![Additional CSS Option in WordPress Site Editor Additional CSS Option in WordPress Site Editor](https://wpdesc.com/wp-content/uploads/2024/06/additional-css-option-in-wordpress-site-editor-1024x467.png)
- Now, you can add custom CSS code to the box that appears in the left sidebar, but make sure the first line of the code is the name of the custom CSS style you entered earlier (i.e., ‘my-custom-block’).
![Adding Custom CSS in WordPress Site Editor Adding Custom CSS in WordPress Site Editor](https://wpdesc.com/wp-content/uploads/2024/06/adding-custom-css-in-wordpress-site-editor-1024x467.png)
NOTE: The benefit of using the site editor is that you see the changes in real time when you add custom CSS to Gutenberg blocks.
Method #2: Add Custom CSS to Gutenberg Blocks via Plugin
If you want a less complicated method to add custom CSS to Gutenberg blocks, all you have to do is install a plugin that allows you to add custom CSS to your blocks straight from the Gutenberg Editor.
- Login to your WordPress dashboard.
- Navigate to ‘Plugins’ → ‘Add New Plugin.’
- Type in ‘Block CSS’ in the search bar.
- Look for “Blocks CSS: CSS Editor for Gutenberg Blocks.”
- Click ‘Install Now’ and then ‘Activate.’
![Blocks CSS Plugin Blocks CSS Plugin](https://wpdesc.com/wp-content/uploads/2024/06/blocks-css-plugin-1024x710.png)
- After activation, open your desired post or page in the Gutenberg editor.
- Select the block that you want to add custom CSS to and open the additional settings by clicking on the Settings icon (which looks like a square with two uneven columns ) in the top right corner.
- Finally, click on the ‘Custom CSS’ option and add your custom CSS code in the box.
![Adding Custom CSS via Blocks CSS Plugin Adding Custom CSS via Blocks CSS Plugin](https://wpdesc.com/wp-content/uploads/2024/06/adding-custom-css-via-blocks-css-plugin-1024x465.png)
That’s it! These are two methods to easily add custom CSS to Gutenberg blocks.
Wrapping Up
To add custom CSS to Gutenberg blocks is a great way to customize your design. In this WordPress Gutenberg tutorial, we have discussed two methods which are:
- Add custom CSS to Gutenberg blocks via WordPress Theme Customizer
- Add custom CSS to Gutenberg blocks via a plugin
We believe that after reading this tutorial, you can now easily add custom CSS to Gutenberg blocks.
However, if you still have any questions, feel free to leave a comment below. We would love to help!
Frequently Asked Questions
How to use CSS in Gutenberg?
With Gutenberg, you can either add custom CSS classes to individual blocks or apply global CSS styles through the WordPress Theme Customizer or dedicated plugins.
How to add CSS in the WordPress Block editor?
To add CSS in the WordPress Block editor, access the block settings directly within Gutenberg, specify the CSS class for a specific block, and then add custom CSS code via the WordPress Theme Customizer. You can also use a plugin such as “Blocks CSS: CSS Editor for Gutenberg Blocks” to add the customer CSS directly from the block (Gutenberg) editor.
How to add custom CSS in WordPress without a plugin?
You can add custom CSS to WordPress without a plugin by going to Theme Customizer and adding CSS code directly there. But first, you need to specify the custom CSS classes inside Gutenberg to style individual blocks.
Leave a Reply