Using the Negation Selector

Description

The negation selector inverts any selection.

Example

The following code shows how to use the Negation Selector.


<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
a:not ([href*="java2s"] ) {
  border: thin black solid;
  padding: 4px;
}<!--from  w  w w.ja v  a 2s .c  om-->
</style>
</head>
<body>
  <a href="http://java2s.com">Visit the website</a>
  <p>
    I like <span>CSS</span> and HTML.
  </p>
  <a href="http://w3c.org">Visit the W3C website</a>
</body>
</html>

Click to view the demo

This selector matches all a elements that don't have an href element that contains the string java2s.





















Home »
  HTML CSS »
    CSS »




CSS Introduction
CSS Background
CSS Border
CSS Box Layout
CSS Text
CSS Font
CSS Form
CSS List
CSS Selectors
CSS Others
CSS Table