Skip to content

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:

  1. Select the block in the Gutenburg Block Editor that you’d like to add a CSS class to.
  2. 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.
  3. Make sure to “Save” or “Update” your post (or page, etc). Then ta-da. You should be good-to-go. 🙂
Yay! 🎉 You made it to the end of the article!
David Hayes
Share:

3 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Claudiu
March 16, 2020 2:17 pm

Hey, I think is important to mention in what file the CSS classes should be defined.
Like you can go to style.css and write the classes.

flowjoe
June 7, 2020 5:59 pm
Reply to  Claudiu

same here, where should they be defined?

Chris Futile
April 12, 2021 5:50 am

Seems not possible with shortcode block, no?

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!