How to Add CSS Classes to a Gutenberg Block
In this text and video Quick Guide, we’ll show you how to add additional CSS classes to a Gutenberg block—that is, a block in the new WordPress editor.
Adding a CSS class to a Gutenberg block is simple, but you’ve got to know where to look for the feature, in “Advanced options” on the right side. The video below explains where to find this option, and how to use it to add one or more CSS classes to any WordPress block.
What a CSS class is: CSS classes are a little bit of HTML markup that makes it easier to style an element using Cascading Style Sheets (CSS). They end up looking like
class="my-css-class" on the HTML element in question. Then designers can write “CSS rules” that make those look a certain way. A common need in web development, both inside WordPress and out of it, is to add an additional CSS class to something on the page.
Video of Adding a CSS Class to a Gutenblock
Here’s the video on how to add a CSS class to a WordPress block in the new “Gutenberg” editor:
Written Steps for Adding a CSS Class to a Block in the WordPress Block Editor
Some of you prefer reading. I got you. Here’s how I add a class HTML element to a WordPress Gutenberg Block:
- Select the block in the Gutenburg Block Editor that you’d like to add a CSS class to.
- In the right sidebar, you should now be on “Block” (vs “Document”) view. When on the “Block” view in the right-sidebar of the editor, the *last* item (at the bottom) will have the title “Advanced.” If you click-to-expand the “Advance” portion of the sidebar, it should reveal a label and field of “Additional CSS Class(es)”. In that field, you’ll add your new CSS classes like:
class1 my-css-class-2 lastCSSClassToAdd.
- Make sure to “Save” or “Update” your post (or page, etc). Then ta-da. You should be good-to-go. 🙂