Skip to content

Commit 2f37630

Browse files
committed
[mediaqueries] Fill in the TODO describing boolean algebra.
1 parent 6bac881 commit 2f37630

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

mediaqueries/Overview.bs

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,47 @@ Combining Media Features {#media-conditions}
656656
using full boolean algebra
657657
(not, and, or).
658658

659-
Issue: TODO: Fill this in.
659+
* Any media feature can be negated by placing ''not'' before it.
660+
For example, ''not (color)'' inverts the meaning of ''(color)''--
661+
since ''(color)'' matches a device with any kind of color display,
662+
''not (color)'' matches a device <em>without</em> any kind of color display.
663+
664+
* Two or more media features can be chained together,
665+
such that the query is only true if <em>all</em> of the media features are true,
666+
by placing ''and'' between them.
667+
For example, ''(width < 600px) and (height < 600px)''
668+
only matches devices whose screens are smaller than ''600px'' wide in both dimensions.
669+
670+
671+
* Alternately, two or more media features can be chained together,
672+
such that the query is true if <em>any</em> of the media features are true,
673+
by plaing ''or'' between them.
674+
For example, ''(update: slow) or (hover: none)''
675+
matches if the device is slow to update the screen (such as an e-reader)
676+
<em>or</em> the device has no hover capability,
677+
perhaps indicating that one should use a layout that displays more information
678+
rather than compactly hiding it until the user hovers.
679+
680+
* <a>Media conditions</a> can be grouped by wrapping them in parentheses ''()''
681+
which can then be nested within a condition the same as a single media query.
682+
For example, ''not (color) or (hover)''
683+
is true on devices that are monochrome
684+
and/or that have hover capabilities,
685+
because the ''not'' only applies to the immediately following ''(color)'' feature.
686+
If one instead wanted to query for a device that was monochrome and <em>didn't</em> have hover capabilities,
687+
it must instead be written as ''not ((color) or (hover))''
688+
(or, equivalently, as ''not (color) and not (hover)'').
689+
690+
It is <em>invalid</em> to mix ''and'' and ''or'' at the same “level” of a media query.
691+
For example, ''(color) and (pointer) or (hover)'' is illegal,
692+
as it's unclear what was meant.
693+
Instead, parentheses can be used to group things using a particular joining keyword,
694+
yielding either ''(color) and ((pointer) or (hover))''
695+
or ''((color) and (pointer)) or (hover)''.
696+
These two have very different meanings:
697+
if only ''(hover)'' is true,
698+
the first one evaluates to false
699+
but the second evaluates to true.
660700

661701
<!--
662702
██████ ██ ██ ██ ██ ████████ ███ ██ ██

0 commit comments

Comments
 (0)