Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

356
Visualizações
Is there a way to add alt attribute to an svg in case it fails to load

Is it possible for me to add an alt attribute to an svg or an icon so that if it fails to load my users can have an idea of what is being rendered there as in images...something like this:

<svg class="header__social--icon">
  <use xlink:href="./data/images/sprite.svg#icon-twitter"></use>
</svg>

now can I have a way to add an alt as in images for example

<svg class="header__social--icon" alt="twitter svg">
  <use xlink:href="./data/images/sprite.svg#icon-twitter"></use>
</svg>

so that if the svg icon cannot be displayed the twitter svg is shown?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Yes, you can. The alt attribute specifies an alternate text for an area, if the image cannot be displayed.

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Refer this link for better understanding.

about 4 years ago · Juan Pablo Isaza Relatório

0

What you could do, is export it as a svg file, then use the img tag, and add an alt to it. Hope this helps. Other than that I dont think there is a way.

Like this:

<img src="path/to/your/svg/imag" alt="this is the alternative text">
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda