is it possible to use a :not() selector with a :nth-of-type(1) selector?
i.e.
I want to select the first
that doesn’t have the title “something”
<html>
<head>
<style type="text/css">
p
{
color:#000000;
}
p:not([title=something]):nth-of-type(1)
{
color:#ff0000;
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p title="something">This is a paragraph.</p>
<p>This is another paragraph.</p>
<p>This is another paragraph.</p>
<div>This is some text in a div element.</div>
</body>
</html>
The
nth-of-typeis acting on the original selector (p), it’s not acting on the result ofp:not([title=something]).This is saying, find the
<p>without a title of “someting” that is also the 1st<p>on the page. This doesn’t find any elements as the 1st<p>has the title “something”.What you want is the 1st
<p>that doesn’t contain the title “something”. I don’t know if CSS has a good way of doing that.If you’re willing to use jQuery, you can use do this:
or: