:in-range and :out-of-range CSS pseudo-classes

:in-range and :out-of-range CSS pseudo-classes

If a temporal or number <input> has max and/or min attributes, then :in-range matches when the value is within the specified range and :out-of-range matches when the value is outside the specified range. If there are no range constraints, then neither pseudo-class matches.

Spec http://www.w3.org/TR/selectors4/#range-pseudos
Status W3C Working Draft
IE Edge Firefox Chrome Safari Opera
    57 62    
    56 61 TP 48
  16 (2) 55 60 11 47
11 15 (2) 54 59 10.1 46
10 14 (2) 53 58 10 (2,3) 45
9 13 (2) 52 57 9.1 (2,3) 44
8 12 51 56 9 (2,3) 43
Show all
7   50 55 8 (2,3) 42
6   49 (3) 54 7.1 (2,3) 41
5.5   48 (3) 53 7 (2,3) 40
    47 (3) 52 (2) 6.1 (2,3) 39 (2)
    46 (3) 51 (2,3) 6 (2,3) 38 (2,3)
    45 (3) 50 (2,3) 5.1 (2,3) 37 (2,3)
    44 (3) 49 (2,3) 5 36 (2,3)
    43 (3) 48 (2,3) 4 35 (2,3)
    42 (3) 47 (2,3) 3.2 34 (2,3)
    41 (3) 46 (2,3) 3.1 33 (2,3)
    40 (3) 45 (2,3)   32 (2,3)
    39 (3) 44 (2,3)   31 (2,3)
    38 (3) 43 (2,3)   30 (2,3)
    37 (3) 42 (2,3)   29 (2,3)
    36 (3) 41 (2,3)   28 (2,3)
    35 (3) 40 (2,3)   27 (2,3)
    34 (3) 39 (2,3)   26 (2,3)
    33 (3) 38 (2,3)   25 (2,3)
    32 (3) 37 (2,3)   24 (2,3)
    31 (3) 36 (2,3)   23 (2,3)
    30 (3) 35 (2,3)   22 (2,3)
    29 (3) 34 (2,3)   21 (2,3)
    28 33 (2,3)   20 (2,3)
    27 32 (2,3)   19 (2,3)
    26 31 (2,3)   18 (2,3)
    25 30 (2,3)   17 (2,3)
    24 29 (2,3)   16 (2,3)
    23 28 (2,3)   15 (2,3)
    22 27 (2,3)   12.1 (2)
    21 26 (2,3)   12 (2)
    20 25 (2,3)   11.6 (2)
    19 24 (2,3)   11.5 (2)
    18 23 (2,3)   11.1 (2)
    17 22 (2,3)   11 (2)
    16 21 (2,3)   10.6 (2)
    15 20 (2,3)   10.5 (2)
    14 19 (2,3)   10.0-10.1 (2)
    13 18 (2,3)   9.5-9.6
    12 17 (2,3)   9
    11 16 (2,3)    
    10 15 (2,3)    
    9 14    
    8 13    
    7 12    
    6 11    
    5 10    
    4 9    
    3.6 8    
    3.5 7    
    3 6    
    2 5    
      4    
iOS Safari Opera Mini Android Browser Blackberry Browser Opera Mobile Android Chrome Android Firefox IE Mobile Android UC Browser Samsung Internet QQ Browser Baidu Browser
11                      
10.3 all (1) 56 10 (2) 37 (2) 59 54 11 11.4 (2) 5 1.2 7.12
10.0-10.2 (2,3)   4.4.3-4.4.4 (2) 7 12.1 (2)     10   4 (2)    
9.3 (2,3)   4.4 (2)   12 (2)              
9.0-9.2 (2,3)   4.2-4.3 (2)   11.5 (2)              
Show all
8.1-8.4 (2,3)   4.1 (2)   11.1 (2)              
8 (2,3)   4 (2)   11 (2)              
7.0-7.1 (2,3)   3   10 (2)              
6.0-6.1 (2,3)   2.3                  
5.0-5.1 (2,3)   2.2                  
4.2-4.3   2.1                  
4.0-4.1                      
3.2                      

Notes

Note that <input type="range"> can never match :out-of-range because the user cannot input such a value, and if the initial value is outside the range, the browser immediately clamps it to the minimum or maximum (as appropriate) bound of the range.

  1. Opera Mini correctly applies style on initial load, but does not correctly update when value is changed.

  2. :in-range also incorrectly matches temporal and number inputs which don't have min or max attributes. See Edge bug, Chrome bug, WebKit bug.

  3. :in-range and :out-of-range incorrectly match inputs which are disabled or readonly. See Edge bug, Mozilla bug, WebKit bug, Chrome bug.

Resources

Data by caniuse.com
Licensed under the Creative Commons Attribution License v4.0.
http://caniuse.com/#feat=css-in-out-of-range

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部