Aggelos Sfakianos
Aggelos Sfakianos

Reputation: 157

Alternative way to use not() pseudoclass in css

So lets say we have N children and we want to use a selector to color them all expect the first child. Is there any possible way to do that without the use of :not(...) pseudo class?? The example is this:

  <!DOCTYPE html>
    <html>
    <head>
    <style> 
p:not(:first-child){
    background: #ff0000;
}
</style>
</head>
<body>

<div><p>This is a paragraph.</p>

<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>



</div>

</body>
</html>

This selects and colors red all children expect the first but i want to do that without the use of :not() .Is there way to do that?

Upvotes: 1

Views: 1785

Answers (2)

Alex Macra
Alex Macra

Reputation: 177

Check this fiddle

Use instead:

 p + p

Upvotes: 0

zombiecode
zombiecode

Reputation: 325

Do it the opposite way round?

<style> 
    p {background:#ff0000;}
    p:first-child {background:none;}
</style>

Upvotes: 1

Related Questions