I have the following:
#cursiva{
font-style: italic;
}
<h1>Titulo de nuestro sitio</h1>
<h2 id="cursiva">Titulo de nuestro sitio</h2>
<h3>Titulo de nuestro sitio</h3>
<h4 class="verde">Titulo de nuestro sitio</h4>
<h5>Titulo de nuestro sitio</h5>
<h6>Titulo de nuestro sitio</h6>
<a href="#" class="verde" id="cursiva">Enlace</a>
<h2>Otro titulo h2</h2>
<p>Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto.
<a href="#" class="verde">Lorem Ipsum</a> ha sido el texto de relleno estándar de las industrias desde
el año 1500, cuando un <span>impresor</span> (N. del T. persona que se dedica a la
imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró
hacer un libro de textos especimen.</p>
<p class="verde">No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos
electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la
creación de las hojas "Letraset", las cuales contenian pasajes de <a href="#" class="verde">Lorem Ipsum</a>,
y más recientemente con software de autoedición, como por ejemplo <span>Aldus PageMaker</span>,
el cual incluye versiones de Lorem Ipsum.</p>
As you can see I have a css identifier and I have applied it to several html elements, the problem is that the styles of that identifier have been applied to the elements in which I have put it.
The doubt is why is it doing this??, I understand that an id only applies to an element even though we have put that identifier on another element, or do I misunderstand that concept??
IDs are used for Javascript; and they must be unique in the HTML. Sure, multiple IDs with different names.
But you can still use this ID in CSS to define styles (but it's not recommended or good practice).
If the ID s are all the same, they will all work the same with CSS, but not with Javascript. Javascript will only identify the first:
These three are valid for CSS, but for javascript only the first one is valid.
Both ways can be used. An ID for Javascript, and a class for CSS:
The ID works the same in CSS and Javascript. Because in CSS it will have styles, and javascript will have a reference.
The difference is that javascript will take only the first ID (in case there are other equal ones).