<number>

  • Revision slug: CSS/number
  • Revision title: number
  • Revision id: 338903
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{CSSRef}}

Summary

The <number> CSS data type represents a number, either integer or fractional. Its syntax extends the one of the {{Xref_cssinteger}} data value. To represent a fractional value, add the fractional part — a '.' followed by one or several decimal digits — to any {{Xref_cssinteger}} data value. Like for {{Xref_cssinteger}} data type, there isn't any unit associated to a <number>, which is not a CSS dimension.

Interpolation

Values of the <number> CSS data type can be interpolated in order to allow animations. In that case they are interpolated as real, floating-point, numbers. The speed of the interpolation is determined by the timing function associated with the animation.

Examples

These are valid number values:

12          A raw <integer> is also a <number>
4.01        A positive non-integer <number>
-456.8      Negative non-integer <number>
0.0         Zero
+0.0        Zero, with a leading +
-0.0        Zero, with a leading - (Though strange, this is an allowed value)
.60         Digits are optional before the dot

These are invalid number values:

12.         The dot should be followed by a number
+---12.2    Only one leading +/- is allowed
12.1.1      Only one dot is allowed
10e3        The e notation is not allowed

Specifications

Specification Status Comment
{{SpecName('CSS3 Values', '#numbers', '<number>')}} {{Spec2('CSS3 Values')}} No significant change from CSS Level 2 (Revision 1)
{{SpecName('CSS2.1', 'syndata.html#numbers', '<number>')}} {{Spec2('CSS2.1')}} Explicitly defined
{{SpecName('CSS1', '', '<number>')}} {{Spec2('CSS1')}} Implicitly defined

Browser compatibility

{{CompatibilityTable}}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
basic 1.0 1.0 (1.0) <=5.0 yes 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support yes yes yes yes yes

See also

Revision Source

<div>{{CSSRef}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>&lt;number&gt;</code> <a href="/en-US/docs/CSS" title="CSS">CSS</a> data type represents a number, either integer or fractional. Its syntax extends the one of the {{Xref_cssinteger}} data value. To represent a fractional value, add the fractional part — a '.' followed by one or several decimal digits — to any {{Xref_cssinteger}} data value. Like for {{Xref_cssinteger}} data type, there isn't any unit associated to a <code>&lt;number&gt;</code>, which is not a CSS dimension.</p>
<h2 id="Interpolation" name="Interpolation">Interpolation</h2>
<p>Values of the <code>&lt;number&gt;</code> CSS data type can be interpolated in order to allow animations. In that case they are interpolated as real, floating-point, numbers. The speed of the interpolation is determined by the <a href="/en-US/docs/CSS/timing-function" title="timing-function">timing function</a> associated with the animation.</p>
<h2 id="Examples" name="Examples">Examples</h2>
<p>These are valid number values:</p>
<pre>
12          A raw <a href="mks://localhost/en/CSS/integer" title="integer">&lt;integer&gt;</a> is also a &lt;number&gt;
4.01        A positive non-integer &lt;number&gt;
-456.8      Negative non-integer &lt;number&gt;
0.0         Zero
+0.0        Zero, with a leading +
-0.0        Zero, with a leading - (Though strange, this is an allowed value)
.60         Digits are optional before the dot
</pre>
<p>These are invalid number values:</p>
<pre>
12.         The dot should be followed by a number
+---12.2    Only one leading +/- is allowed
12.1.1      Only one dot is allowed
10e3        The e notation is not allowed
</pre>
<h2 id="Specifications" name="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr style="background-color: rgb(255, 204, 255);">
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('CSS3 Values', '#numbers', '&lt;number&gt;')}}</td>
      <td>{{Spec2('CSS3 Values')}}</td>
      <td>No significant change from CSS Level 2 (Revision 1)</td>
    </tr>
    <tr style="vertical-align: top;">
      <td style="vertical-align: top;">{{SpecName('CSS2.1', 'syndata.html#numbers', '&lt;number&gt;')}}</td>
      <td style="vertical-align: top;">{{Spec2('CSS2.1')}}</td>
      <td style="vertical-align: top;">Explicitly defined</td>
    </tr>
    <tr>
      <td style="vertical-align: top;">{{SpecName('CSS1', '', '&lt;number&gt;')}}</td>
      <td style="vertical-align: top;">{{Spec2('CSS1')}}</td>
      <td style="vertical-align: top;">Implicitly defined</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<p>{{CompatibilityTable}}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari (WebKit)</th>
      </tr>
      <tr>
        <td>basic</td>
        <td>1.0</td>
        <td>1.0 (1.0)</td>
        <td>&lt;=5.0</td>
        <td>yes</td>
        <td>1.0 (85)</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Phone</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>yes</td>
        <td>yes</td>
        <td>yes</td>
        <td>yes</td>
        <td>yes</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li><a href="/en-US/docs/CSS/CSS_Reference" title="CSS Reference">CSS Reference</a> index</li>
  <li>CSS Data Types : {{CSSDataTypes}}</li>
</ul>
Revert to this revision