I have a few HTML tables. These tables do not have CSS classes. The two tables have width="100%"
attribute. Other tables don't have the width
attribute.
Using only CSS I need to set the width of the tables which don't have width=100%
. Something like this:
table:not(width="100%"){ width: myValue; }
:not() The :not() CSS pseudo-class represents elements that do not match a list of selectors. Since it prevents specific items from being selected, it is known as the negation pseudo-class. /* Selects any element that is NOT a paragraph */ :not(p) { color: blue; }
The :not(selector) selector is used to style every element that is not specified by the selector. Since it prevents specific items from being selected, it is also known as the negation pseudo-class. Example: In this example, we have used the :not selector and paragraph element.
The :not() property in CSS is a negation pseudo class and accepts a simple selector or a selector list as an argument. It matches an element that is not represented by the argument. The passed argument may not contain additional selectors or any pseudo-element selectors.
:not() Back :not() is a CSS negation pseudo-class selector. It is a functional pseudo-class selector that takes a simple selector as an argument, and then matches one or more elements that are not represented by the argument.
Attribute selectors are surrounded by []
, so your selector should look like this instead:
table:not([width="100%"]) { width: myValue; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With