Custom CSS to individual blocks in the Gutenberg editor

Gutenberg is the WordPress editor that was introduced in WordPress 5.0. It is a block-based editor that enables users to create content using blocks such as paragraphs, headings, images, videos, and more. One of the powerful features of Gutenberg is the ability to add custom CSS to individual blocks, which allows users to modify the styling of a block to suit their needs.

Custom CSS in Gutenberg can be added using the “Additional CSS Class” field, which is available in the “Block” settings panel. This field allows users to add a custom class to a block and then use that class in their custom CSS. Here’s how you can add custom CSS to a Gutenberg block:

  1. Click on the block to select it.
  2. In the block settings panel, click on the “Advanced” tab.
  3. In the “Additional CSS Class” field, add a custom class name. For example, you could add “my-custom-class”.
  4. Click “Update” to save the changes to the block.

Once you have added a custom class to the block, you can use that class in your custom CSS. To add custom CSS to your Gutenberg block, follow these steps:

  1. Click on the block to select it.
  2. In the block settings panel, click on the “Advanced” tab.
  3. In the “Additional CSS Class” field, add a custom class name. For example, you could add “my-custom-class”.
  4. Click “Update” to save the changes to the block.
  5. Click on the “Edit as HTML” option in the block settings panel.
  6. Locate the <style> tag in the HTML code and add your custom CSS rules. For example, you could add the following CSS code to change the font color of the block to red:
cssCopy code.my-custom-class {
  color: red;
}
  1. Click on the “Preview” button to see the changes in action.

Adding custom CSS to a Gutenberg block gives you more control over the styling of your content and allows you to create more customized designs that better suit your needs. However, it’s important to note that adding custom CSS can also make your site slower and harder to maintain, so it’s recommended that you only add custom CSS when it’s necessary and keep it to a minimum.

One Comment

  • My spouse and I stumbled over here coming from a different page and thought I
    might check things out. I like what I see so i am just following you.
    Look forward to looking at your web page yet again.

Leave a Comment

Your email address will not be published. Required fields are marked *