--- title: <frequency> slug: Web/CSS/frequency tags: - CSS - Web - 参考 translation_of: Web/CSS/frequency --- <div>{{CSSRef}}</div> <p><span><code><frequency></code> <a href="/en-US/docs/Web/CSS">CSS</a></span>数据类型表示频率维度,例如语音的音高。目前它未在任何 CSS 属性中被使用。</p> <h2 id="语法">语法</h2> <p>The <code><frequency></code> data type consists of a {{cssxref("<number>")}} followed by one of the units listed below. As with all CSS dimensions, there is no space between the unit literal and the number.</p> <h3 id="单位">单位</h3> <p>可以使用以下单位:</p> <dl> <dt><code><a id="Hz" name="Hz">Hz</a></code></dt> <dd>表示以赫兹(hertz)为单位的频率。例如:<code>0Hz</code>、<code>1500Hz</code>、<code>10000Hz</code>。</dd> <dt><code><a id="kHz" name="kHz">kHz</a></code></dt> <dd>表示以千赫兹(kilohertz)为单位的频率。例如:<code>0kHz</code>、<code>1.5kHz</code>、<code>10kHz</code>。</dd> </dl> <div class="note"> <p><strong>Note:</strong> Although the number <code>0</code> is always the same regardless of unit, the unit may not be omitted. In other words, <code>0</code> is invalid and does not represent <code>0Hz</code> or <code>0kHz</code>. Though the units are case-insensitive, it is good practice to use a capital "H" for <code>Hz</code> and <code>kHz</code>, as specified in the <a class="external" href="https://en.wikipedia.org/wiki/International_System_of_Units">SI</a>.</p> </div> <h2 id="示例">示例</h2> <pre>12Hz Positive integer 4.3Hz Non-integer 14KhZ The unit is case-insensitive, though non-SI capitalization is not recommended. +0Hz Zero, with a leading + and a unit -0kHz Zero, with a leading - and a unit</pre> <h3 id="Invalid_frequency_values">Invalid frequency values</h3> <pre class="example-bad">12.0 This is a <number>, not an <frequency>, because it is missing a unit. 7 Hz No space is allowed between the number and the unit. 0 Although unitless zero is an allowable <length>, it's an invalid <frequency>.</pre> <h2 id="规范">规范</h2> <table class="standard-table"> <thead> <tr> <th scope="col">规范</th> <th scope="col">状态</th> <th scope="col">备注</th> </tr> </thead> <tbody> <tr> <td>{{SpecName('CSS3 Values', '#frequency', '<frequency>')}}</td> <td>{{Spec2('CSS3 Values')}}</td> <td>Initial definition</td> </tr> </tbody> </table> <div class="note"> <p><strong>Note:</strong> This data type was initially introduced in <a class="external" href="https://www.w3.org/TR/CSS2/aural.html#q19.0">CSS Level 2</a> for the now-obsolete <a href="/en-US/docs/Web/CSS/@media/aural" title="aural">aural</a> <a href="/en-US/docs/Web/CSS/@media#Media_types">media type</a>, where it was used to define the pitch of the voice. However, the <code><frequency></code> data type has been reintroduced in CSS3, though no CSS property is using it at the moment.</p> </div> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("css.types.frequency")}}</p>