: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.
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) { /* 样式规则 */ }
where:
:not
is the selector type.selector
is 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; }
Other examples:
li:not(.active)
:not(table)
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!