CSS

CSS Overview Selectors Declarations Rule Sets Comments Reset/Normalize Origin Importance Order Specificity Inheritance Cascade Layers Inline Styles Internal Styles External Styles @import Absolute Units Relative Units Dynamic Viewport Angle Units Time Units Frequency Units: Resolution Units Keywords Color Formats Color Functions & Spaces Background Color Background Image Background Repeat Background Position Background Size Background Attachment Background Shorthand Multiple Backgrounds Linear Gradients Radial Gradients Conic Gradients Font Family Font Size Font Weight Font Style Line Height Text Align Text Decoration Text Transform Letter Spacing Word Spacing Text Shadow Text Wrap Variable Fonts Content Box Padding Box Border Box Margin Box Box Sizing Property Margin Padding Border Outline Box Shadow Block Display Inline Display Inline Block Display Static Position Relative Position Absolute Position Fixed Position Sticky Position Top Element Position Right Element Position Bottom Element Position Left Element Position Z Index Flexbox Box Layout Display Flex Flex Direction Flex Wrap Justify Content Align Items Align Content Gap, Row Gap & Column Gap Flex Grow Flex Shrink Flex Basis Flex Shorthand Order Property Align Self Practical Applications CSS Grid Layout Grid Display Grid Template Columns Grid Template Rows Grid Template Areas Justify Items Grid Auto Columns Justify Self Nested Grids Responsive Web Design Min Width Max Width Orientation Logical Operators Pointer Hover Prefers Color Scheme Fluid Images Flexible Typography Viewport Width Advanced CSS Features Defining variables Using variables Scope & Inheritance of CSS Variables Property Value Fallback Practical Applications :Hover :Active :Focus :Focus Visible :Visited :Link :First Child :Last Child :Nth Child :Nth of Type :Empty :Checked :Disabled :Enabled :Valid :Invalid :Required :Has :Not :Is :Where ::Before Pseudo Element ::After Pseudo Element ::First Letter ::First Line ::Selection ::Marker CSS 2D Transformations CSS 3D Transformations Transform Origin Transform Style Backface Visibility Transition Property Transition Duration Transition Timing Function Transition Delay Transition Shorthand Ease Timing Function Linear Timing Function Ease In Timing Function Ease Out Timing Function Ease In Out Timing Function Cubic Bezier Function Animations (@keyframes) Defining @keyframes Animation Name CSS Animation Duration Animation Timing Function CSS Animation Delay CSS Animation Iteration Count Animations Direction CSS Animation Fill Mode CSS Animation Play State CSS Filter Blur CSS Filter Brightness CSS Filter Contrast() CSS Drop Shadow CSS Grayscale CSS Hue Rotate CSS Invert CSS Opacity CSS Saturate CSS Sepia Mix Blend Mode Background Blend Mode Object Fit & Object Position Scroll Snap Type Scroll Snap Align Scroll Padding Scroll Margin Scroll Triggered Animations JS Variables

Frequency Units:


In CSS, frequency units are used to specify the pitch of a voice in aural style sheets. These style sheets are designed for screen readers and other speech-synthesis browsers to render documents audibly. The two frequency units available are Hertz (Hz) and kilohertz (kHz).


Hertz (Hz)

This unit represents the number of cycles per second. A higher value corresponds to a higher pitch. For example, 100Hz represents one hundred cycles per second.

Example 1: Setting a Basic Voice Pitch

/* Sets the average pitch of the speaking voice for the entire page */
body {
  pitch: 120Hz;
}

Explanation This code sets a baseline pitch of 120Hz for the voice synthesizer reading the document's body content. This creates a moderately low-pitched voice.


Example 2: Changing Pitch for Emphasis

/* Makes emphasized text have a slightly higher pitch */
em {
  pitch: 140Hz;
}

Explanation Here, the em element is styled to have a pitch of 140Hz. This makes any emphasized text stand out by being spoken at a slightly higher tone.


Example 3: Lowering Pitch for Strong Importance

/* Lowers the pitch for text marked as strong */
strong {
  pitch: 100Hz;
}

Explanation This rule gives strong elements a lower pitch of 100Hz. A deeper voice is often associated with seriousness or importance in speech.


Example 4: Defining a Pitch Range

/* Sets a narrow pitch range for headings */
h1 {
  pitch-range: 20Hz;
  pitch: 150Hz;
}

Explanation This example uses pitch-range to control the variation in pitch. By setting a low pitch-range of 20Hz and a base pitch of 150Hz, the heading will be read in a more monotone and steady high-pitched voice.


Example 5: Pitch for Blockquotes

/* Sets a distinct, lower pitch for blockquotes */
blockquote {
  pitch: 95Hz;
}

Explanation Assigning a unique, low pitch of 95Hz to the blockquote element helps to aurally distinguish quoted text from the main content, similar to how it is visually indented.


Kilohertz (kHz)

The kilohertz unit is equivalent to 1000 Hertz. It is used for specifying very high-frequency pitches, though it is less common in practical aural CSS.

Example 1: Setting a High Pitch with kHz

/* Sets a very high pitch for a specific class */
.high-note {
  pitch: 0.2kHz; /* Equivalent to 200Hz */
}

Explanation This code sets the pitch for any element with the class high-note to 0.2kHz. This is the same as 200Hz and results in a very high-pitched voice.


Example 2: Pitch for Abbreviation Readouts

/* Specifies a higher pitch for acronyms and abbreviations */
abbr {
  pitch: 0.18kHz; /* Equivalent to 180Hz */
}

Explanation This rule targets the abbr element, setting its pitch to 0.18kHz (180Hz). This can help signal to the listener that the text is an abbreviation.


Example 3: Distinguishing Code Snippets Aurally

/* Sets a unique pitch for preformatted text or code */
pre, code {
  pitch: 0.11kHz; /* Equivalent to 110Hz */
}

Explanation By applying a pitch of 0.11kHz (110Hz), this CSS makes screen readers pronounce code blocks and inline code in a distinct, slightly lower tone.


Example 4: Using kHz for a Header

/* Defines a high pitch for a secondary heading */
h2 {
  pitch: 0.16kHz; /* Equivalent to 160Hz */
}

Explanation This example sets the pitch for all h2 elements to 0.16kHz, or 160Hz. This ensures secondary headings are read in a consistently high tone.


Example 5: Extremely High Pitch for Effect

/* Uses a very high pitch for a special alert class */
.alert-sound {
  pitch: 0.3kHz; /* Equivalent to 300Hz */
}

Explanation This rule uses 0.3kHz (300Hz) to create an unusually high-pitched voice for elements with the alert-sound class, grabbing the listener's attention for important alerts.