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

157
Vistas
How to add another property in css?

Suppose if we give some properties to all h1 tags using external css and we have to give one more property (not present in css) to only one of the h1 tag with same remaining properties in css.So do I have to write seperate code by giving that tag a id or there is any shorter way?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

two classes sounds like the right way to go, even better than generic h1 tag directly, for example:

index.html

<div>
  <h1 class="generic-class">generic</h1>
  <h1 class="generic-class">generic</h1>
  <h1 class="generic-class specific-class">specific</h1>
</div>

style.css

generic-class {
  color: red
}
.specific-class {
  font-weight: 800
}

This way, all of them are red, and the last one is red and bold too.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Another solution is to add inline css code directly into the style attribute of the element. In the snippet below I show multiple ways of selecting which element you want to edit with various selectors and js functions.

Though you should keep in mind it's better to have only 1 <h1> on a webpage, mostly for SEO purposes.

// Select h1 by query, for example query below selects the first h1
let h1 = document.querySelector('h1:first-of-type');
h1.style.color = "black";

// Select h1 by id
let h1_2 = document.getElementById('h1_to_select');
h1_2.style.color = "blue";

// Select h1 by index
let h1_3 = document.getElementsByTagName('h1')[1];
h1_3.style.color = "green";
h1{
  font-size:16px;
  font-family:sans-serif;
  color:red
}
<h1>This is a h1 title</h1>
<h1>This is a h1 title</h1>
<h1>This is a h1 title</h1>
<h1 id="h1_to_select">This is a h1 title</h1>
<h1>This is a h1 title</h1>
<h1>This is a h1 title</h1>

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