Style Encapsulation in ASP.NET MVC Rich Text Editor Control
18 Nov 20181 minute to read
Style encapsulation determines how styles are applied within the Syncfusion ASP.NET MVC Rich Text Editor. This feature helps control whether the component’s content inherits global styles from the application or remains isolated.
Encapsulation modes
The Rich Text Editor offers two rendering modes for controlling style encapsulation:
-
Encapsulated Mode (Iframe Mode)
- When enabled, the Rich Text Editor is rendered inside an
<iframe>. - The application’s global CSS rules will not affect the content inside the editor.
- This ensures that the editor’s content remains styled independently.
-
Usage:
IframeSettings(iframeSettings => iframeSettings.Enable(true))
- When enabled, the Rich Text Editor is rendered inside an
-
Non-Encapsulated Mode (Default)
- The Rich Text Editor is rendered without an
<iframe>. - The application’s global CSS will apply to the content inside the editor.
- This mode allows seamless integration with existing styles.
-
Usage:
IframeSettings(iframeSettings => iframeSettings.Enable(false))
- The Rich Text Editor is rendered without an
Default behavior
By default, the Rich Text Editor uses non-encapsulated mode (IframeSettings(iframeSettings => iframeSettings.Enable(false))), allowing the application’s styles to affect the editor’s content.
Below is a sample implementation of both encapsulated and non-encapsulated modes.