Set span tag CSS in sibling mode
4 answers
Due to how the CSS selector works, there is no previous sibling selector. Thus, with your existing markup, you cannot use pure CSS for this.
If the link appeared after the div, however:
<div id="someDiv"></div> <a id="link"><span>Some Text</span></a> The selector to be used will be #someDiv:hover + #link span .
+5
This may be possible if you have a parent to bind the hss cover class. For instance: -
<div id="parent"> <div id="someDiv"></div> <a id="link"><span>Some Text</span></a> </div> & den use the following css.
#link { position:absolute; /*This is to ensure the hover is activated only on the someDiv div & as absolutely positioned elements are removed from the normal flow of the document*/ /*You can position this anchor tag wherever you want then */ } #parent:hover > link > span { color:#000; /*enter code here/* } +2
I think this should work, assuming that these two elements have the same parent, and a#link is the first child of this parent.
#parent div#someDiv:hover ~ a#link:first-child span { color: blue; } IE6 does not support it , but if you can live without IE6 (and you really should, IMO), you should be fine.
0