CSS3 > Selectors

Not selector in CSS3

How to add style to the every element on the webpage except the specified element in CSS3?


By using not selector we can add style to the every element on the webapge except to the specified element. That means the not slelctor gives style to the every element except to the selected element.

<style>
        p {
            color: green;
        }

        :not(p) {
            color: none;
        }
</style>

<body>
    <b>This is b element</b>
    <p>This is p element</p>
    <p>This is P element</p>
    <div>
        This is the div element.
    </div>
</body>

In the above code snippet we have given colour "green"  to the <p> element and for other elements colour "none" is given. That is shown in the below output clearly.

This means that color = 'none' is getting applied to all element that is not 'p'.

OUTPUT

 Views: 550 | Post Order: 30



Write for us