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

188
Views
How to scope the css properties of <style> tag within a svg?

I have a <style> tag inside a svg image with background-color property set to white. And I am dynamically adding this svg to the HTML. As the background-color is set to white, all other svgs on the webpage are inheriting this property which is unwanted. It seems the properties are applied globally, but I want to scope the property to this single svg or this single div

Earlier there was scope attribute for <style> which is now removed. How can I achieve this, specially in angular. Angular view encapsulation is not working in this case.

<div class="svg-image">
    <svg>
        <style>
        svg {
            background-color: white;
        }
        </style>
        <g>
        .
        .
        </g>
    </svg>
</div>

Edit: A similar question is answered here

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

0

apply custom class to your svg as folows,

app.component.html

<div class="svg-image">
    <svg class="svg-background-white">
        <g>
        .
        .
        </g>
    </svg>
</div>

app.component.css

.svg-background-white {
  background-color: white;
}
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!