frequency

  • Revision slug: Web/CSS/frequency
  • Revision title: frequency
  • Revision id: 446625
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The <frequency> CSS data types denotes a frequency dimension, like the pitch of a speaking voice. They consists of a {{ Xref_cssnumber() }} immediately followed by the unit. Like for any CSS dimension, there is no space between the unit literal and the number.

The following units may be used :

  • Hz which represents a frequency in Hertz. E.g. 0Hz, 1500Hz, 10000Hz.
  • kHz which represents a time in kilohertz. E.g. 0kHz, 1.5kHz, 10kHz.

Even if all units represent the same time for the value 0, the unit may not be omitted in that case as it isn't a {{ xref_csslength() }}: 0 is invalid and does not represent 0Hz, 0kHz. Though the units are case-insensitive in CSS, it is good practice to use a capital H for Hz and kHz, as in the SI, Hertz being a family noun.

Examples

These are valid frequency values:

12Hz        Positive integer.
-456kHz     Negative integer.
4.3Hz       Non-integer.
14KhZ       The unit is case-insensitive, though non-SI capitalization is not recommended.
+0s         Zero, with a leading + and the unit.
-0ms        Zero, with a leading - and the unit (Though strange, this is an allowed value).

These are invalid frequency values:

12.0        This is a <number>, not an <frequency>, it must have a unit.
7 Hz        No space is allowed between the <number> and the unit.
0           Zero values can be written without a unit only if there are <length> values, not <frequency>.

Specifications

Specification Status Comment
{{ SpecName('CSS3 Values', '#frequency', '<frequency>') }} {{ Spec2('CSS3 Values') }}  

This data type was initially introduced in CSS Level 2 for the now obsoleted aural media group, where it was used to define the pitch of the voice. This has been deprecated since then, but the <frequency> data type has been reintroduced in CSS3, though no CSS property is using it at the moment.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} [*] {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

[*] Some versions of Opera may have (partial) support for the obsolete aural media group, and through the pitch property support for the <frequency> data type.

See also

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>&lt;frequency&gt;</code> <a href="/en/CSS" title="CSS">CSS</a> data types denotes a frequency dimension, like the pitch of a speaking voice. They consists of a&nbsp;<span class="lang lang-en">{{ Xref_cssnumber() }}</span> immediately followed by the unit. Like for any CSS dimension, there is no space between the unit literal and the number.</p>
<p>The following units may be used :</p>
<ul>
  <li><code><a id="Hz">Hz</a></code> which represents a frequency in Hertz. E.g. <code>0Hz</code>, <code>1500Hz</code>, <code>10000Hz</code>.</li>
  <li><code><a id="kHz">kHz</a></code> which represents a time in kilohertz. E.g. <code>0kHz</code>, <code>1.5kHz</code>, <code>10kHz</code>.</li>
</ul>
<p>Even if all units represent the same time for the value <code>0</code>, the unit may not be omitted in that case as it isn't a {{ xref_csslength() }}: <code>0</code> is invalid and does not represent <code>0Hz</code>, <code>0kHz</code>. Though the units are case-insensitive in CSS, it is good practice to use a capital H for <code>Hz</code> and <code>kHz</code>, as in the <a class="external" href="http://en.wikipedia.org/wiki/International_System_of_Units" title="http://en.wikipedia.org/wiki/International_System_of_Units">SI</a>, <a class="external" href="http://en.wikipedia.org/wiki/Heinrich_Hertz" title="http://en.wikipedia.org/wiki/Heinrich_Hertz">Hertz</a> being a family noun.</p>
<h2 class="editable" id="Examples"><span>Examples</span></h2>
<p>These are valid frequency values:</p>
<pre>
12Hz&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Positive integer.
-456kHz&nbsp;&nbsp;&nbsp;&nbsp; Negative integer.
4.3Hz       Non-integer.
14KhZ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; The unit is case-insensitive, though non-SI capitalization is not recommended.
+0s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Zero, with a leading + and the unit.
-0ms        Zero, with a leading - and the unit (Though strange, this is an allowed value).
</pre>
<p>These are invalid frequency values:</p>
<pre>
12.0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is a <a href="mks://localhost/en/CSS/number" title="en/CSS/number">&lt;number&gt;</a>, not an &lt;frequency&gt;, it must have a unit.
7 Hz        No space is allowed between the <a href="mks://localhost/en/CSS/number" title="en/CSS/number">&lt;number&gt;</a> and the unit.
0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Zero values can be written without a unit only if there are <a href="mks://localhost/en/CSS/length" title="en/CSS/length">&lt;length&gt;</a> values, not &lt;frequency&gt;.
</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', '#frequency', '&lt;frequency&gt;') }}</td>
      <td>{{ Spec2('CSS3 Values') }}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<p>This data type was initially introduced in <a class="external" href="http://www.w3.org/TR/CSS2/" title="http://www.w3.org/TR/CSS2/">CSS Level 2</a> for the now obsoleted <a href="/en/CSS/Aural" title="aural">aural</a> <a href="/en/CSS/@media#Media_groups" title="https://developer.mozilla.org/en/CSS/@media#Media_groups">media group</a>, where it was used to define the pitch of the voice. This has been deprecated since then, but the <code>&lt;frequency&gt;</code> data type has been reintroduced in CSS3, though no CSS property is using it at the moment.</p>
<h2 id="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</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}} [*]</td>
        <td>{{CompatNo}}</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 Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
        <td>{{CompatNo}}</td>
      </tr>
    </tbody>
  </table>
</div>
<p>[*] Some versions of Opera may have (partial) support for the obsolete aural media group, and through the pitch property support for the <code>&lt;frequency&gt;</code> data type.</p>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en/CSS_Reference" title="CSS Reference">CSS Reference</a> index</li>
  <li>CSS Data Types : {{ CSSDataTypes() }}</li>
</ul>
Revert to this revision