Elemento de sección de orientación en CSS

can you please let me know how to target a section element with a specific id like #dress in CSS3? Here is the code which I have:

<section id="dress">
 <p> Lorem Ipsum.................................. of Lorem Ipsum.<>

y el estilo:

section #dress{
    background-color: #cdcdcd;

Pero no está funcionando

preguntado el 12 de febrero de 14 a las 05:02

1 Respuestas

El espacio, , es el Selector de descendientes. The selector that you want is section#dress.

However, I think that this selector is not easy to maintain. Instead, it would be better to use #dress so that you can select the element irrespective of its type.

As an addendum to that, there is a suggestion out there that says that you should stick to classes pretty much exclusively for selectors in CSS because of the specificity rules that are applied to IDs. For example, say you had to change the styles for this #dress en una fecha posterior:

#dress {
    background-color: #cdcdcd;
.label-list {
    background-color: #dcdcdc;

Ahora si tuvieras <section id="dress" class="label-list">, the background would still be #cdcdcd aunque .label-list follows in the cascade. You may want to stick to classes for styles. This is just a suggestion, though, and not a hard rule.

Respondido 12 Feb 14, 05:02

Thanks Explosion Pills it works now, I need to have 12 minutes to accept this answer as correct one, however! - user1760110

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.