---
title: ':out-of-range'
slug: 'Web/CSS/:out-of-range'
tags:
  - CSS
  - Layout
  - Pseudo-class
  - Web
translation_of: 'Web/CSS/:out-of-range'
---
<div>{{CSSRef}}</div>

<p>The <a href="/en-US/docs/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class </a><a href="/en-US/docs/Web/CSS">CSS</a> <strong><code>:out-of-range</code></strong> representa un element {{htmlelement("input")}} el valor actual del qual està fora dels límits de rang especificats pels atributs {{htmlattrxref("min", "input")}} i {{htmlattrxref("max","input")}}.</p>

<pre class="brush: css no-line-numbers">/* <span id="result_box" lang="ca"><span>Selecciona qualsevol</span></span> &lt;input&gt;,  <span id="result_box" lang="ca"><span>però només quan té un rang especificat, i el seu valor està fora d'aquest rang</span></span> */
input:out-of-range {
  background-color: rgba(255, 0, 0, 0.25);
}</pre>

<p>Aquesta pseudo-class és útil per proporcionar a l'usuari una indicació visual de que el valor actual d'un camp està fora dels límits permesos.</p>

<div class="note"><strong>Nota:</strong> Aquesta pseudo-class només s'aplica als elements que tenen (i poden prendre) una limitació de rang. A falta d'aquesta limitació, l'element no pot ser "dins del rang" ni "fora de rang".</div>

<h2 id="Sintaxi">Sintaxi</h2>

{{csssyntax}}

<h2 id="Example" name="Example">Exemple</h2>

<div id="example">
<h3 id="HTML">HTML</h3>

<pre class="brush: html">&lt;form action="" id="form1"&gt;
  &lt;ul&gt;Values between 1 and 10 are valid.
    &lt;li&gt;
      &lt;input id="value1" name="value1" type="number" placeholder="1 to 10" min="1" max="10" value="12"&gt;
      &lt;label for="value1"&gt;Your value is &lt;/label&gt;
    &lt;/li&gt;
  &lt;/ul&gt;
&lt;/form&gt;</pre>

<h3 id="CSS">CSS</h3>

<pre class="brush: css;">li {
  list-style: none;
  margin-bottom: 1em;
}

input {
  border: 1px solid black;
}

input:in-range {
  background-color: rgba(0, 255, 0, 0.25);
}

input:out-of-range {
  background-color: rgba(255, 0, 0, 0.25);
  border: 2px solid red;
}

input:in-range + label::after {
  content: 'okay.';
}

input:out-of-range + label::after {
  content: 'out of range!';
}</pre>

<h3 id="Resultat">Resultat</h3>
</div>

<div>{{EmbedLiveSample('Example', 600, 140)}}</div>

<h2 id="Especificacions">Especificacions</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Especificació</th>
   <th scope="col">Estat</th>
   <th scope="col">Comentari</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'scripting.html#selector-out-of-range', ':out-of-range')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Defineix quan <code>:out-of-range</code> coincideix en elements HTML.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS4 Selectors', '#out-of-range-pseudo', ':out-of-range')}}</td>
   <td>{{Spec2('CSS4 Selectors')}}</td>
   <td>Definició inicial.</td>
  </tr>
 </tbody>
</table>

<h2 id="Navegadors_compatibles">Navegadors compatibles</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Descripció</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Suport en &lt;input&gt;</td>
   <td>10.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("29.0")}}</td>
   <td>{{CompatNo()}}</td>
   <td>11.0</td>
   <td>5.2</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Descripció</th>
   <th>Android</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Suport en &lt;input&gt;</td>
   <td>2.3</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("16.0")}}</td>
   <td>{{CompatNo()}}</td>
   <td>{{CompatVersionUnknown()}}</td>
   <td>{{CompatVersionUnknown()}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="Vegeu_també">Vegeu també</h2>

<ul>
 <li>{{cssxref(":in-range")}}</li>
 <li><a href="/en-US/docs/Web/Guide/HTML/Forms/Data_form_validation">Validació de dades del formulari</a></li>
</ul>