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

66
Visualizações
Styling the HTML tags that are created in javascript

If i use HTML tags inside javascript file, how can i select them and use them in a css file?

for example: javascript: <li id="id"> name </li>

how can i select and use id in the stylesheet?

I tried it this way but it didnt work #id li { background: red;}

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

0

either you can use the JS also add style to the Element.

document.getElementById(id).style.property = new style

Add inline style using Javascript

Or you need to load the script before the style.

about 4 years ago · Juan Pablo Isaza Relatório

0

If you assign a id to any tag or element you don't need to use element or tag name to style it. Directly use id. by #id li { background: red; } it means inside the element(which has id) it search for another li element. Try

#id {
  background: red;
}
about 4 years ago · Juan Pablo Isaza Relatório

0

I would avoid using ids as they have to be unique (no more than one per page). If you have to target specific list items use data attributes.

ul li[data-type="name"] { color: red; }
<ul>
  <li data-type="name">Bobby</li>
  <li data-type="age">26</li>
</ul

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