R
ReGenesis0
So I've got this thing...
I want to apply css styles to a link if it's the first piece of
content within a LI, but /not/ if it's got anything before it.
<li> <a>Styled!</a> <li>
<li> This is <a>not styled!</a> <li>
I'm targeting the element I want to style with:
li > a:first-child { background-colorink; }
And that works... insofar that if there are 2 <a>'s, only the first ti
styled, and if there are any child elements before the <a> (like a
<span>) then <a> is not styled.
But-- it doesn't do what i want if there is TEXT before the :first-
child node...
<li> This is <a>not styled!</a> <li>
The <a> is still styled, even though I want it not to be.
Approaching this from a DOM perspective, I would think that text-nodes
would count as children, and disqualify <a> from being a first-
child. ...but this is not the case.
Is there anything I can combine this with to get the effect I
want? :first-letter doesn't seem to fit the bill... but maybe I'm
just not thinking sideways enough?
Am I just out of luck?
-Derik
I want to apply css styles to a link if it's the first piece of
content within a LI, but /not/ if it's got anything before it.
<li> <a>Styled!</a> <li>
<li> This is <a>not styled!</a> <li>
I'm targeting the element I want to style with:
li > a:first-child { background-colorink; }
And that works... insofar that if there are 2 <a>'s, only the first ti
styled, and if there are any child elements before the <a> (like a
<span>) then <a> is not styled.
But-- it doesn't do what i want if there is TEXT before the :first-
child node...
<li> This is <a>not styled!</a> <li>
The <a> is still styled, even though I want it not to be.
Approaching this from a DOM perspective, I would think that text-nodes
would count as children, and disqualify <a> from being a first-
child. ...but this is not the case.
Is there anything I can combine this with to get the effect I
want? :first-letter doesn't seem to fit the bill... but maybe I'm
just not thinking sideways enough?
Am I just out of luck?
-Derik