user2032816
user2032816

Reputation: 21

Applying style inside LI

A program generates the following HTML

<blah blah blah> 
  <li class="compact class_x class_y">
  <label class=label/>
  <select>...</select>
  </li>
<blah blah blah>

Is there a way to apply styles to the li and the labels and select inside it, but no others?. In other words, whenever I have a compact style, I want to apply changes to the li, the label and select inside. The label has a class already, and the select has no class. I can't modify the html.

Thanks in advance!

Upvotes: 0

Views: 489

Answers (2)

Michael
Michael

Reputation: 7092

HTML:

<blah class="something">
    <li></li>
    <label />
    <select></select>
</blah>

CSS:

.something > li {}
.something > label {}
.something > select {}

You can replace .something with whatever <blah> is. I assume you have multiple of these and each needs to be different?

Upvotes: 0

gotohales
gotohales

Reputation: 3695

You should just be able to use

.compact {
/* li styles */
}

.compact label {
/* label styles in compact class */
}

.compact select{
/* select styles in compact class */
}

Upvotes: 3

Related Questions