:not - HTML CSS CSS Selector

HTML CSS examples for CSS Selector:not

Description

The :not(selector) selector negates the selection.

Example

Select all elements that are not a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
p {<!--from w w w . j  a v a 2s .  c om-->
    color: #000000;
}

:not(p) {
    color: #ff0000;
}
</style>
</head>
<body>

<h1>This is a heading</h1>

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

<div>This is some text in a div element.</div>

<a href="https://www.java2s.com" target="_blank">Link!</a>

</body>
</html>

Related Tutorials