Jump to content

Refer to first occurrency of element with classname “foobar”?


pstein

Recommended Posts

Assume the following code:

<div class="foobar" ....>   // target
   <div class="foobar" ...>....</div>
</div>
<div class="foobar" .... >....</div>

Now I want to assign a new CSS rule to only the first element which has the class “foobar”. In the sample above the

with “target” as comment.
How can I address this?
[foobar]:first { color: red }

or

.foobar:first { color: red }

do not work

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...