Limiting Block-Level Styles in Drupal 8's CKEditor

Published March 15, 2016

By default, Drupal 8's "Basic HTML" text format WYSIWYG editor configuration allows content authors to utilize HTML heading elements "h2" through "h5". 

Default settings for "Basic HTML" text format.

But what if you want to limit authors to a smaller set of block-level HTML elements? In previous versions of Drupal, this would require separate configuraiton of both the text format and the WYSIWYG editor. In Drupal 8, the solution is much simpler - simply limit the text format to use the block-level elements to be allowed (in this case, h4, h5, h6 - the "id" indicates that HTML "id" attributes may be specified on these elements as well):

Configuring the "Basic HTML" text format to only allow h4, h5, and h6 elements.

The WYSIWYG editor automatically displays only those that are allowed by the updated text format!

Updated WYSIWYG configuration.



This works great!

Submitted by Jeff Phillips (not verified) on Tue, 03/15/2016 - 23:29

Glad you like the simplicity, and the overall solution :)

Submitted by Wim Leers (not verified) on Wed, 03/16/2016 - 06:16

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!