CKEditor SDK - index

Applying Styles to Editor Content Documentation

The Styles drop-down list contains styles that you can apply to editor content in order to assign semantic value to the text you are creating in CKEditor. It is provided by the Styles Combo plugin which by default is available in the Standard and Full distributions.

When the Styles Combo plugin is enabled, the button is automatically added to the toolbar. Once clicked, it opens a drop-down list with styles that can be applied to your content. The styles are categorized into groups, depending on their target, so you can use block, inline, object and widget styles for the content that you are creating. If you want to quickly remove inline and object styles from your document, use the   button provided by the Remove Format plugin.

Default Styles Combo Plugin Implementation

Please note that the default styles available in the drop-down list are defined in the styles.js file and are just examples which will not work without the matching contents.css file. They will also not work in the inline editor which uses page stylesheets instead of the contents.css file. Refer to the Applying Styles to Editor Content article to learn more about this feature.

Widget Styles

Widgets are special rich content units and therefore standard styles (like block or object ones) cannot be applied to them. Only styles of a special type ('widget') work with widgets. The styles are defined for particular widget types and more than one style can be applied to a widget instance. Refer to the Widget Styles section for more information.

The editor below presents widget styles for the captioned image, embedded media and mathematical formulas.

Stylesheet Parser Plugin

The optional Stylesheet Parser plugin fills the Styles drop-down list based on the CSS rules available in the stylesheet defined in the config.contentsCss option.

A few configuration options are available to fine-tune this feature, including using regular expressions to choose or limit CSS selectors that will be available for editor content. Refer to the Stylesheet Parser documentation to learn more about this feature.

Note: The default styles configuration was cleared in the editor instance below. The default styles are thus not applied to editor content and the only styles available in the Styles drop-down are those coming from the document stylesheet provided in the editor configuration.

Related Features