I am new to SharePoint, and I am trying to put a background color for the titles on my page. Here is the code,

       <style type="text/css">
.ms-webpart-titleText > a {
    background-color: black;
    /* changes the background color of the web part header.  Hex too! #000000 */

    font-size: 20px;
    /* Font Size */

    font-weight: bold;
    /* Font bold, italics, */

    color: white;
    /*Font color */

    padding: 5px 5px;
    /*padding around fonts */

When I input the code in edit mode it looks fine, but when i hit save the background reverts back to white. Also, I can't pull up content editor on my web part tool as well.

  • Is the CSS still there when you edit the web part again? If not, then you will store the CSS in a file, and then link to that file from the CEWP. Jun 26, 2018 at 1:25

1 Answer 1


Add “?contents=1” at the end of the url of the page, e.g. "/<site>/<page>.aspx?contents=1” to open Web Part Page Maintenance page, check whether the Content Editor web part exists and is opened on this page. See if the web part is inserted to this page successfully.

enter image description here

In SharePoint Online, we can also use Script Editor web parts. Check it and compare the results.

Besides, try using !important in the script. For example: background-color: black !important;

  • Hi, I opened the web part page but the content editor title wasn't there. Also I tried the !important too but it also did not work.
    – kpguy123
    Jun 26, 2018 at 16:50
  • The Content Editor web part was not added to the page successfully. Are using IE? Try using IE. Insert a Content Editor web part -> Enter the script -> Apply -> OK -> Save the page. Jun 27, 2018 at 1:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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