New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

External CSS Files

In this help article you will learn how to import external CSS files into the content area of RadEditor using the CssFiles collection.

This approach is available only when ContentAreaMode is iframe. Using a content area rendered as a DIV element does not offer native capabilities to add external CSS files. You can find out how to decorate the DIV content area here—Decorating Div Content Area.

By default, RadEditor uses the CSS styles available in the current page. Using the CssFiles collection, it can be configured to load external CSS files instead.

If a CSS file is added via the CssFiles collection, any CSS rules or files that derive from the main page will no longer affect the stylization of the content area.

Using external CSS files is useful in scenarios where the editable content area is required to have design, formatting or stylization that is different from the main page.

Thanks to the CssFiles collection, you can add multiple CSS files to the RadEditor content area, as shown in the examples below.

Example 1: Adding external CSS files via markup.

<telerik:RadEditor RenderMode="Lightweight" runat="server" ID="RadEditor1">
        <telerik:EditorCssFile Value="~/ExternalCssFiles/Styles1.css" />
        <telerik:EditorCssFile Value="~/ExternalCssFiles/Styles2.css" />

Example 2: Adding external CSS files from the code behind.


If you want to set external CSS files in dynamically loaded editors, make sure to load the Toolsfile before you add any external css files, e.g.

`RadEditor1.ToolsFile = "~/RadEditorTools-Simple.xml";`
`RadEditor1.CssFiles.Add(new EditorCssFile("~/Css/RadEditor.css"));`

Example 3: Adding external CSS files via ToolsFile.xml file.

        <item name="~/ExternalCssFiles/Styles1.css" />    
        <item name="~/ExternalCssFiles/Styles2.css" /> 

Example 4: Example of an external CSS file.
    color: #0000ff;
    font-weight: normal;
    font-style: italic;
    border: none;
    background-color: Red;
    font-size: 10px;

The CSS classes available in the external CSS files will populate the Apply Css Class dropdown. If you need to rearrange the items populated in the tool you need to use the CssClasses collection to add the ones that should be visible for the end-user.

If you only want to stop the page style inheritance, you do not need to have a special blank stylesheet. An empty value for the CssFile will have the same effect and will avoid the unnecessary request:

- - -
    <telerik:RadEditor RenderMode="Lightweight" ID="RadEditor1" runat="server">
            <telerik:EditorCssFile Value="" />

See Also

In this article