Type: Object
Default: false
This setting allows you to automatically add CSS classes to the specified tags.
Redactor('#entry', {
classes: {
tags: {
'p': 'my-paragraph',
'h2': 'my-heading my-heading-another-class'
}
}
});
Now the specified classes will be added to tags in the content inside the editor and in the output code.
Tags inside the editor have a reset of styles, so to specify them CSS rules, you need to set styles like this:
.rx-content .my-paragraph {}
.rx-content .my-heading {}
.rx-content .my-heading-another-class {}
Redactor regards the content as certain blocks. Therefore, you can set up a class not only for individual tags but also for groups of tags that are combined into these blocks. Here are the blocks of content that Redactor has:
Here is how to specify for certain blocks the automatic adding a class when starting the editor, when pasting or inserting content and so on.
Redactor('#entry', {
classes: {
blocks: {
'image': 'my-image',
'heading': 'my-heading'
}
}
});
In this example, all blocks with images and all headers will automatically receive the specified classes.
And here's how to set classes for both blocks and tags at the same time:
Redactor('#entry', {
classes: {
blocks: {
'image': 'my-image',
'heading': 'my-heading'
},
tags: {
'p': 'my-paragraph'
}
}
});