Friday, December 26, 2008

Predefine styles in HTML editor in MOSS

A quick note about predefining custom styles in a HTML editor:
Standard, the HTML editor detects CSS classes whose names have the prefix .ms-rteCustom. You can easily extend the OOTB styles by adding .ms-rteCustom-XXX to your custom stylesheet. The name "XXX" will then become available in the styles dropdown within the HTML editor.

Another option is to specify a unique CSS class name prefix. This give you the ability to present different custom styles for different HTML editors of the publishing page. To make a unique CSS class, you have to assign a PrefixStyleSheet property to the HTML field control.

<.PublishingWebControls:RichHtmlField id="Content" FieldName="PublishingPageContent" runat="server" PrefixStyleSheet="myUniqueClass"./>
Afterwards you can define the "myUniqueClassCustom" class in you custom stylesheet.
Warning: you have to append the word "Custom" to the class, otherwise it won't work! In my opinion, MS doesn't explain this very well...


Syntax = .[PrefixStyleSheetPropertyName]Custom-[TitleAvailableInEditor]

font-weight: bold;
font-size: 16px;

Read How to: Customize Styles for more information.


Anonymous said...

I have a strange issue here - the custom styles are visible only to one person. Even if I make another user site collection admin, he does not see the styles.
Is there any solution?

komakino said...

Verify the permissions of the library where the stylesheet lives in...


Anonymous said...

the user is a site collection admin - I guess that person should have all permissions, even if not explicitely granted, is that right?
Thank you :)

komakino said...

Have you published your stylesheet? Normally you just need read permissions to see the styles.