Wrapping Gutenberg Blocks with a div/section/article

I would like to be able to create sections of blocks from within the Gutenberg editor. This way I can apply styles around groups of blocks.

The idea would be to either:

  • Nest one or more blocks within a container div/section/article
  • Add an opening tag before a block or group of blocks and a closing tag afterwards

I have tried adding a ‘Custom HTML’ block before and afterwards with opening/closing tags. This works apart from when revisiting the editor the you’re welcomed with a ‘This block contains unexpected or invalid content’ warning.

How can I achieve this?

2 Answers
2

Use ‘Groups’: If you do not see the ‘Group’ option, like me, you’ll have to update WP.

After that, simply create a group, then add new blocks or drag existing blocks into it. Select the group and add HTML Anchors and classes via the ‘Advanced’ tab of the block’s menu.

Leave a Comment