Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda