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

350
Visualizações
Weird HTML <style> tag, does not have content but the style rule exists

First, Sorry for my bad English, I hope you can understand what I mean.

I wanna ask why these style rule exist when the style tag had no content, I had no Idea what is it. These inspector screenshot was captured on TransferWise Dashboard,


Image 1.

Image 1.


On Image 1. (red) it has class .css-1r17gmu and had the rule padding 24px, border-radius 0px, display flex, etc, but when I click the style location reference (blue), the style tag had no content. (Image 2 - Below)


Image 2

Image 2.


I wanna copy the style to my project, but had no idea how is this, and how to create it,

When I try to Delete-Undo the style tag (Image 2, blue background), the tag remain the same, but the style is gone.

Thats my Question, I dont know if this has a duplicate since I dont know the keyword.

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

0

This effect can be achieved by inserting rules into the stylesheet with .insertRule, which results in the rule on the <style> tag in question applying to elements in the DOM, but without inserting HTML markup into the <style> tag. You can see it on that site by selecting the style tag in the inspector, and then doing console.dir($0.sheet.cssRules) in the console:

enter image description here

If you want to copy the style contained there, you'll have to iterate over the .cssRules.

Live example of this behavior:

document.querySelector('#theStyle').sheet.insertRule('.foo { background-color: yellow; }');
// Text content is still empty:
console.log(document.querySelector('#theStyle').textContent);
<style id="theStyle"></style>
<div class="foo">foo</div>

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