What are the elements in the excluded section of css selector

下次还敢
Release: 2024-04-06 02:42:16
Original
1018 people have browsed it

:not() selector can be used to exclude elements under specific conditions, its syntax is :not(selector) {style rule}. Examples: :not(p) excludes all non-paragraph elements, li:not(.active) excludes inactive list items, :not(table) excludes non-table elements, div:not([data-role="primary"]) Exclude div elements with non-primary roles.

What are the elements in the excluded section of css selector

Selector to exclude some elements in CSS

:not() selector is used to exclude elements that match specific conditions element. Here's how to use the :not() selector:

:not(selector) { /* 样式规则 */ }
Copy after login

where:

  • :notis the selector type.
  • selectoris the selector of the element to exclude.

Example:

To exclude all elements that are not paragraphs, you can use the following selector:

:not(p) { color: red; }
Copy after login

Other examples:

  • Exclude elements with specific class names:li:not(.active)
  • Exclude elements that are not in the table::not(table)
  • Exclude elements with specific attributes:div:not([data-role="primary"])

The above is the detailed content of What are the elements in the excluded section of css selector. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!