CSS <frequency> Data Type
The CSS <frequency> data type represents a frequency value. It consists of a number followed by either the Hz or kHz unit and is used by CSS features that accept frequency-based values.
Syntax
A <frequency> value consists of a <number> immediately followed by a frequency unit:
<frequency> = <number>Hz | <number>kHz
Examples of frequency values include:
440Hz
1000Hz
1kHz
2.5kHz
There must not be a space between the number and the unit.
Frequency Units
CSS provides two units for representing frequency values:
| Unit | Name | Description |
|---|---|---|
Hz |
Hertz | Represents one cycle per second. |
kHz |
Kilohertz | Represents 1,000 cycles per second. |
CSS units are ASCII case-insensitive, so forms such as Hz, hz, and HZ are equivalent. The conventional forms Hz and kHz are generally used for readability.
Converting Frequency Units
One kilohertz is equal to 1,000 hertz. Values expressed with either unit can therefore represent the same frequency:
1kHz = 1000Hz
1.5kHz = 1500Hz
0.5kHz = 500Hz
Zero Values
A frequency of zero can be written with a frequency unit, such as 0Hz or 0kHz. When a CSS grammar requires a <frequency>, a unit should be included because a unitless 0 is a <number>, not a <frequency>.
0Hz
0kHz
<frequency> Examples
The following values are examples of valid CSS frequencies:
| Value | Equivalent Frequency |
|---|---|
440Hz |
440 hertz |
1kHz |
1,000 hertz |
2.5kHz |
2,500 hertz |
0.25kHz |
250 hertz |
The <frequency> data type is primarily a unit and syntax definition, so its usefulness depends on a CSS feature that accepts frequency values.
Specifications
The <frequency> data type and its units are defined in the CSS Values and Units Module Level 4 .
