0

I try to apply some styles to the list. I added CEWP into the page and edited the source. It is CEWP's source:

<style type="text/css">
body{background-color:white;}
</style>

It doesn't work. Why doesn't it work? I'm using SP 2013.

2 Answers 2

1

Chances are there is another style that is overwriting your style that is either more specific, or loaded after yours.

Try using Firefox with the Firebug add-on or the Chrome Developer tools in Google Chrome to select the element and see what styles are being applied and from where.

Or, if you're just trying to change the background color for a list, it wouldn't be the body tag that you'd be styling. It's much more specific than that. Like I said above, your best bet is to open the page and use the developer tools to find out the class you should be targeting.

3
  • the id of the div which includes the list web part is"WebPartWPQ2 . I found this web site and did what he says and nothing worked. link '<style type="text/css">#MSOZoneCell_WebPartWPQ2 .ms-WPHeader{background-color:white;}</style>'
    – e.ozmen
    Mar 12, 2013 at 8:09
  • Ok I did it. Thank you. <style type="text/css">#MSOZoneCell_WebPartWPQ2{background-color:white;}</style>
    – e.ozmen
    Mar 12, 2013 at 8:25
  • Follow the instructions here and make sure you don't mix up zeros and O's. erikswenson.blogspot.com/2009/01/…
    – Keith
    Aug 28, 2013 at 13:29
0

Have you wrapped your css in a style tag like:

<style type="text/css">
body
{
...
}
</style>

?

5
  • Yes, I did but nothing works
    – e.ozmen
    Mar 11, 2013 at 11:36
  • Have you tried styling another element on the page? Or tried using the !important attribute on the style rule? It is possible that your rule is overruled by standard corev4.css or any other css file Mar 11, 2013 at 11:38
  • No. On the page there is just one list and the content editor wp is on the top of it. So it has to style only that list. I didn't use !important.
    – e.ozmen
    Mar 11, 2013 at 11:41
  • Well no mather if the list is the only thing on the page, sharepoint will still use all rules from corev4.css as a base style. Sometimes the corev4 is harder to override than you wish. But trying to style other elements on the page could help you see if your css is loaded at all (like making some text change color) Mar 11, 2013 at 11:45
  • I put a div with class called "CustomPart" and changed "body" into ".CustomPart",nothing happened.
    – e.ozmen
    Mar 11, 2013 at 11:52

Your Answer

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

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