You can use conjunctions (and), disjunctions (or), and/or negations (not) to combine two or more property/value pairs in a @supports condition. However, when using conjunctions, disjunctions and/or negations together, you must observe the following rules:
- When using both
andandor, you must use parentheses to define the order in which they apply. If you don't, the condition is considered invalid and the whole rule is ignored; - When combining
notwithandand/ororoperators, you must wrap the wholenotexpression with parentheses (unless thenotexists on its own at the top level). Otherwise, the whole rule is ignored.
To give you some ideas on how you could make use of conjunctions, disjunctions and/or negations together, consider the following examples:
@supports (-ms-ime-align: auto) and (overflow-wrap: break-word) {
/* ... */
}
@supports (height: 100vh) and ((transform-style: preserve) or (-moz-transform-style: preserve)) {
/* ... */
}
@supports (-ms-ime-align: auto) and (not (overflow-wrap: break-word)) {
/* ... */
}
In the following examples, since not exists on its own at the top level, you do not need to wrap it in parentheses:
@supports not ((transform-style: preserve) or (-moz-transform-style: preserve)) {
/* ... */
}
@supports not ((transform-style: preserve) and (-moz-transform-style: preserve)) {
/* ... */
}
This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.