Setting Text and Background Color Documentation
The optional Text and Background Color feature is provided through the Color Button plugin which by default is available in the Full distribution.
When the plugin is enabled, the Remove Format plugin.
and buttons are automatically added to the toolbar. You can use them to add some color to your content. If you want to quickly remove colors from your document, use the button provided by theMore Colors Option and Color Dialog
You can also add an optional Color Dialog plugin which provides the More Colors option and a user-friendly way to select the desired color through a dedicated dialog window. The editor instance below includes both features.
Custom Color List
Allowing your users to use any colors they wish might lead to undesired results, i.e. joyfully colorful content
that will make your page look like it was created in the early 1990s. You can prevent this situation by customizing the
color list to only include a limited number of colors that match your website style. The editor instance below
uses the config.colorButton_colors
option to trim down the color list to a selected few.
Additionally, since CKEditor 4.5.8 you can also disable the "Automatic" option by setting the config.colorButton_enableAutomatic
option to false
. The editor instance below includes customizations.
Related Features
- Styling and Formatting – Copying Text Formatting
- Styling and Formatting – Removing Text Formatting
- Styling and Formatting – Basic Text Styles: Bold, Italic and More
- Styling and Formatting – Applying Styles to Editor Content
- Styling and Formatting – Applying Block-Level Text Formats
Get Sample Source Code
- Text and background color with Color Dialog
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <title>Text and background color with Color Dialog</title> <script src="https://cdn.ckeditor.com/4.14.0/standard-all/ckeditor.js"></script> </head> <body> <textarea cols="80" id="editor1" name="editor1" rows="10" data-sample-short><p>This is some <strong>sample text</strong>. You are using <a href="https://ckeditor.com/">CKEditor</a>.</p></textarea> <script> CKEDITOR.replace('editor1', { height: 250, extraPlugins: 'colorbutton,colordialog' }); </script> </body> </html>
- Custom text and background colors
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="robots" content="noindex, nofollow"> <title>Custom text and background colors</title> <script src="https://cdn.ckeditor.com/4.14.0/standard-all/ckeditor.js"></script> </head> <body> <textarea cols="80" id="editor2" name="editor2" rows="10" data-sample-short><p>This is some <strong>sample text</strong>. You are using <a href="https://ckeditor.com/">CKEditor</a>.</p></textarea> <script> CKEDITOR.replace('editor2', { height: 250, extraPlugins: 'colorbutton', colorButton_colors: 'CF5D4E,454545,FFF,CCC,DDD,CCEAEE,66AB16', colorButton_enableAutomatic: false }); </script> </body> </html>