tags:

views:

25

answers:

1
+1  Q: 

CSS Style Question

Hi,

In the following style:

.slider div div div h2 span { color:#ae663d;}

What is the purpose of "div div div"?

+3  A: 

It specifies that the rule applies to span tags, contained in h2 tags, contained in three nested divs, under a tag with class 'slider'.

Something like this, where the <span> containing "here" will be matched:

<body class="slider">

  <div>
    <div>
      <div>
        <h2>Header text <span>here</span></h2>
      </div>
    </div>
  </div>

</body>
meagar
Cool, that was what I thought but I wasn't sure if those divs were just duplicated or if the original author meant to do that because it seems like there should be a better way to target this the span since the number of divs its nested in could change.
Kory
@Kory It's definitely not a good idea to use a complex hierarchy to select something. Chances are `.slider h2 span` would have been specific enough.
meagar
+1 meagar ; Also, complex hierarchies like that can be avoided by the judicious use of classes/ids on the elements, too.
Andrew Barber