sNewbie
sNewbie

Reputation: 77

How to prevent CSS inheritance of background color?

There is a main page in CSS that inherits this.. but we are allowed to work only in a portal version of the site. We want to change the background color but somehow it is unable to change due to its inheritance from the main CSS. It is a company with many agencies and within that agency there are many depts with different web sites. We belong to one of those department. Suggestions? How to suppress the background or even change the background to a different color. Thanks

Upvotes: 1

Views: 2243

Answers (1)

domsson
domsson

Reputation: 4681

From your description, it is really hard to tell what's going on here. However, knowing a bit of CSS, there are usually several things you could try to override rules:

  • CSS rules are read from top to bottom; rules that come later (within the same source) will override previous rules
  • More specific rules are prioritized over less specific rules. You should be able to override an p { background-color: #fff; } with, for example, #content #main p.note { background-color: #fff; }
  • Inline-Styles (<tag style="background-color:#fff">...</tag>) have priority over those in the html's head or linked CSS files
  • Using !important (like this: background-color:#fff !important;) will tell the browser to prioritize your rule over other rules

Maybe one of those will do the trick for you.

Upvotes: 3

Related Questions