We have around 100 multiple users using a SharePoint Application.

When editing each page, document, list or library item, users are styling the textual content as per their own styles, which results in an inconsistency of styles for the textual content across the whole SharePoint website.

Please let me know how I can control this to get the same appearance of the whole website, with my own styles defined in the standard style sheet.

  • Can you please elaborate some more? What is your objective? Do you want to block the users from defining new inline styles or you just want to provide some common use stylesheet classes? – Hitodama Apr 22 '13 at 12:09
  • I want to use some common style sheets in the same way, I want to block the users not use much inline styles. – Ram Apr 22 '13 at 14:31

You seem to have two problems there:

  1. You want to include some common css files in all you pages. This is easy to accomplish.
  2. You want to seal the ability to use inline styles in custom pages / webpart and such. This is hard (or impossible) to do.

For the first problem the solution is actually quite easy:

Define a module that adds you stylesheet to the style library of a site collection (or use the _layouts folder if your environment does not allow for the Publishing infrastructure to be available).

All you need to do then is to create a site scoped feature that will deploy the module and leverage a delegate control to add the css registration on all the site pages (note: there is an alternate technique that registers scripts and css using a custom action, but I don't think you need that).

Another technique would be to include the css references in your masterpage (that would be especially simple if you already are using a custom masterpage).

Your second problem is more problematic, and no simple way comes to mind to solve that.

One idea could be to abuse "!important" declarations and very high priority css selectors in your .css file...Bbut that could easily be overridden by circumventing your selectors.

Just think about it: Suppose you have a content editor web part, how can you enforce some policy so that no inline style can be added in its content?

If you REALLY need to, and must support, any situation (even the case where the user uses an OOTB web part on which you have almost no control) I fear the only solution is some sort of javascript / jquery usage to fix the css on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.