View Single Post
Old 07-11-2008, 09:54 PM   #1 (permalink)
delayedinsanity
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default adjacent selectors should allow for different elements

I just started implementing child selectors and adjacent siblings selectors into my CSS - previous to now I had used alternate classes or direct styles added to certain elements to get the effects I wanted, but I figured why not take advantage of what was available.

The problem I'm having is that it seems like adjacent sibling selectors (+) don't work with the body element. Anybody know why?

Code:
body + div {
/* css */
}
...should affect the first div element if it directly follows the body, but it doesn't. I tried to work around this by adding a span before the first div, and using the selector like so:

Code:
span + div {
/* css */
...almost worked, but it's affected all the divs, which it should only affect the first. I even tried some random elements like STRONG, just to mess around and see if it would work, but notta.

The adjacent selector is supposed to work on different elements but it seems so far that it only supports similar simple elements. p + p, h1 +h2, etc. No body + anything, or span + div...
-m
delayedinsanity is offline  
Reply With Quote