You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: files/en-us/web/css/css_conditional_rules/using_feature_queries/index.md
+108-6Lines changed: 108 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -40,7 +40,31 @@ For example, we can apply a set of styles or import an entire stylesheet if the
40
40
41
41
As another example, if you want to check if a browser supports the `row-gap` property you would write the following feature query. It doesn't matter which value you use in a lot of cases: if all you want is to check that the browser supports this property, then any valid value will do.
If your browser supports the row-gap property, the border will be dashed and
46
+
text will be red.
47
+
</div>
48
+
```
49
+
50
+
```css live-sample___simple
51
+
body {
52
+
font: 1.2em / 1.5sans-serif;
53
+
}
54
+
.box {
55
+
border: 4pxsolidblue;
56
+
color: blue;
57
+
padding: 1em;
58
+
}
59
+
@supports (row-gap: 10px) {
60
+
.box {
61
+
border: 4pxdasheddarkgreen;
62
+
color: red;
63
+
}
64
+
}
65
+
```
66
+
67
+
{{EmbedLiveSample("simple")}}
44
68
45
69
The value part of the property-value pair matters more if you are testing for new values of a particular property. All browsers support `color: red`: this dates back to CSS1. However, there are often additional values added to properties in CSS, like [relative colors](/en-US/docs/Web/CSS/CSS_colors/Relative_colors), which may not be supported. Feature queries enable testing property and value pairs, meaning we can detect support for values.
46
70
@@ -71,7 +95,31 @@ In addition to asking the browser if it supports a feature, you can test for the
71
95
72
96
The CSS inside the following example feature query will run if the browser does not support `row-gap`.
If your browser does not support row-gap, the content will be darkgreen with a
101
+
dashed border.
102
+
</div>
103
+
```
104
+
105
+
```css live-sample___not
106
+
body {
107
+
font: 1.2em / 1.5sans-serif;
108
+
}
109
+
.box {
110
+
border: 4pxsolidblue;
111
+
color: blue;
112
+
padding: 1em;
113
+
}
114
+
@supportsnot (row-gap: 10px) {
115
+
.box {
116
+
border: 4pxdasheddarkgreen;
117
+
color: darkgreen;
118
+
}
119
+
}
120
+
```
121
+
122
+
{{EmbedLiveSample("not")}}
75
123
76
124
## Testing for more than one feature
77
125
@@ -86,7 +134,32 @@ You may need to test support for more than one property in your feature query. T
86
134
87
135
For example, if the CSS you want to run requires that the browser supports CSS Shapes and CSS grid, you could create a rule that tests browser support for both of these features. The following rule will only return true if `shape-outside: circle()` and `display: grid` are both supported by the browser.
0 commit comments