0

What does the "+" symbol stand for in css style. What does the below code infer
#mainDiv label + a { }

Smartuser
  • 3
  • 1
  • have a look here: http://www.edition-w3.de/TR/1998/REC-CSS2-19980512/kap05.html – basilikum Jun 17 '13 at 07:36
  • 1
    @basilikum: Not only is that a really old spec, but it's also in German. Unless you know the OP understands German, it's probably not a good idea to link to a non-English resource. – BoltClock Jun 17 '13 at 07:44
  • @BoltClock oh boy, I think I'm not really awake yet. Here is a link to the english spec: http://www.w3.org/TR/CSS2/selector – basilikum Jun 17 '13 at 07:50

3 Answers3

2

It targets an a that follows a label nested within #mainDiv.

<div id="mainDiv">
    <label></label>
    <a>This element.</a>
</div>
Marty
  • 39,033
  • 19
  • 93
  • 162
0

+ means adjacent selector.

In your case it means if <a> tag is found directly after <label> tag inside the mainDiv then apply the css.

Example:

<div id="mainDiv">
    <label>Label Text</label>
    <a>Link</a> <!-- Your CSS will apply to this -->
</div>
Starx
  • 77,474
  • 47
  • 185
  • 261
0

It is Adjacent sibling combinator.

The adjacent sibling combinator is made of the "plus sign" (U+002B, +) character that separates two sequences of simple selectors. The elements represented by the two sequences share the same parent in the document tree and the element represented by the first sequence immediately precedes the element represented by the second one.

AllTooSir
  • 48,828
  • 16
  • 130
  • 164