Home > Web Front-end > Front-end Q&A > How to exclude selection in css

How to exclude selection in css

WBOY
Release: 2022-04-20 15:06:57
Original
3616 people have browsed it

In CSS, you can use the ":not" selector to exclude selection. This selector will match every element that is not a specified element, that is, to exclude the specified element. The syntax is "Element: not (specify elements to be excluded){css style code}".

How to exclude selection in css

The operating environment of this tutorial: Windows 10 system, CSS3&&HTML5 version, Dell G3 computer.

How to perform exclusive selection in css

:not(selector) The selector matches each element of the non-specified element/selector.

":not" is a type of selector. If you want a certain style not to apply to the selector, you can use :not (selector)

The syntax is:

:not(selector)
Copy after login

Examples are as follows:

<html>
<head>
<style>
p
{
color:#000000;
}
:not(p)
{
color:#ff0000;
}
</style>
</head>
<body>
<h1>这是标题</h1>
<p>这是一个段落。</p>
<p>这是另一个段落。</p>
<div>这是 div 元素中的文本。</div>
<br>
<a href="#" target="_blank">这是一个a标签</a>
</body>
</html>
Copy after login

Output results:

How to exclude selection in css

(Learning video sharing: css video tutorial)

The above is the detailed content of How to exclude selection in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template