The Content Editor Web Part

The Content Editor Web Part (CEWP) allows you to add text, html, scripts or styles to a SharePoint page. Its versatility makes it a favorite among Web designers.

The site offers a tutorial on how to add a CEWP to a page:

The CEWP has two edit options:
– Rich Text Editor: as it says, allows you to add formatted text.
– Source Editor: this is a more powerful option, allowing you to add html, scripts or styles.

Note that the CEWP is not the only Web Part to allow you to add html to your pages. In some cases you may also consider the Form Web Part or the Page Viewer Web Part.

Looking for examples?

You’ll find on the Web many examples of how to use the CEWP. There’s even a whole site dedicated to it:

Many scripts were introduced for SharePoint 2003, usually they’ll also work in SharePoint 2007 (after all, they just use JavaScript). This is not the case for styles, as some ids and class names have changed from SharePoint 2003 to SharePoint 2007.

If you add scripts or styles, you’ll usually choose to hide the CEWP (check the “Hidden” box under Layout).

If you break your Web page…

When playing with the CEWP, you run the risk of adding bad code that will break your page. SharePoint will then throw out an error message, without offering any way to undo your changes.
If this happens to you, here is a useful trick: append the “?contents=1” querystring to your URL. It will give you access to the maintenance page, where you’ll be able to get rid of the faulty Web part.
For example, if you inadvertently break this page:

A trick to edit Web Part pages

On some pages, the edit option is not available or is grayed out. This is for example the case for the edit form of a list.
The workaround here is to append the “?ToolPaneView=2” querystring to your URL, which will switch your page to edit mode. Note that it seems to be unsupported by Microsoft, though I haven’t read an official confirmation.
For example, if you want to edit:

32 thoughts on “The Content Editor Web Part

  1. When you’re looking at a page you want to edit, just click the bookmark and you’ll be presented with the same page, but with “?ToolPaneView=2” enabled.

  2. Pingback: No assembly required « Path to SharePoint

  3. Pingback: Adding extra content to a list form - From SharePoint with love

  4. Pingback: The Content Editor Web Part « Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

  5. The whole CEWP + JS trick is excellent. However, I find that it doesn’t work for lookup columns. In designing the calculated expression, lookup columns aren’t listed. I know the MS docs list this as a limitation of WSS 3.0 but is there a workaround so that we can do work of a lookup column?

  6. Pingback: Image rotator: build your own! « Path to SharePoint

  7. Pingback: The Content Query Web Part « Path to SharePoint

  8. Pingback: Using calculated columns to write HTML « Path to SharePoint | Rickey Whitworths Blog

  9. Pingback: Content Editor Web Part - surpoint 2

  10. Hello,

    One of my friend told me that if you hide the CWEP, the script won’t apply anymore. Is that right ?


  11. Hi All,

    I have a Telerik RadEditor on the sharepoint and iam unable to edit the webpart. How can i edit the webpart, please suggest.

    The “modify webpart option ” doesn’t appear eventhough i have clicked on “edit page” from site actions.

    IMP:- the webpat uses 3 images all of which are of size 567X113 pixels.

    Awaiting reply

  12. Pingback: Tasks Lists Roll-up beta, available for download « Path to SharePoint

  13. Pingback: About Scripts, Web Parts and Urban Myths « Path to SharePoint

  14. Pingback: Openen van URL’s in een nieuwe browser in SharePoint « Joost van Lier's Blog

  15. I love the “?ToolPaneView=2” querystring to edit forms…do you have a quick JS code to be able to format fields like phone numbers?

  16. Hi!

    Very good the post. I have a question i did it and it is works fine, but… when i put a group by in the list it is not working? Do you know the solution?


  17. Pingback: Bridging the gap between the users and IT « Path to SharePoint

  18. Thanks for the inspriation…

    I did something similar with jquery. In my calcuated column, I added a ‘calculated-column’ class to my wrapping div to find it easier.

    //change html escaped text from calulated column to the innerHTML
    $(‘.ms-vb2’).each(function (index) {
    if (this.innerText.indexOf(‘calculated-column’) > 0) {
    this.innerHTML = this.innerText;

  19. I believe 1 of your ads triggered my internet browser to resize, you may want to put that on your blacklist.

  20. It’s actually a great and helpful piece of info. I’m happy that you just shared this helpful info with us. Please stay us up to date like this. Thanks for sharing.

  21. The best as well as the model of promotions commonly
    are different while using backer also, the model of keepsake
    provided. Once connected, you can easily transfer videos and music to your system
    from your Media Center PC, chat with friends, play games via Xbox Live and more, all without the clutter of wires.
    This revolutionary latest smart cell phone perfectly brings entertainment, work,
    and family together all in one place with Live Tiles.

Comments are closed.