Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Override background-color using `!important`

How do I override class background color? Tried !important but not working, the text is still yellow.

<!DOCTYPE html>
<html>
<head>
<style>
.myclass {
  background-color: yellow ;
}
</style>
</head>
<body>

<p class="myclass" background-color="red !important">This is some text in a paragraph.</p>

</body>
</html>

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

if you want use inline styles (not good), you should use style attribute on html elements and in any way of using css you should use colon : instead of = for giving value to properties, try this snippet:

<!DOCTYPE html>
<html>

<head>
  <style>
    .myclass {
      background-color: yellow;
    }
  </style>
</head>

<body>

  <p class="myclass" style="background-color:red !important;">This is some text in a paragraph.</p>

</body>

</html>

about 4 years ago · Juan Pablo Isaza Report

0

You need to put inline css in the style attribute like so:

<!DOCTYPE html>
<html>
<head>
<style>
.myclass {
  background-color: yellow ;
}
</style>
</head>
<body>

<p class="myclass" style="background-color: red !important;">This is some text in a paragraph.</p>

</body>
</html>

about 4 years ago · Juan Pablo Isaza Report

0

You need to mention style.

<p class="myclass" style="background-color:red !important;">This is some text in a paragraph.</p>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!