Questions
38 of 45
1What is a pseudo-element in CSS?
2How are pseudo-elements different from pseudo-classes?
3What is the syntax of a pseudo-element?
4Name some commonly used pseudo-elements.
5What does the ::before pseudo-element do? What does the ::after pseudo-element do?
6How can you insert content using pseudo-elements?
7What is the difference between :before and ::before? Why were pseudo-elements changed from one colon (:) to two (::) in CSS3?
8What does the ::first-letter pseudo-element do?
9What does the ::first-line pseudo-element do?
10How can you style the first line of a paragraph differently?
11Can pseudo-elements be styled with animations or transitions?
12What’s the difference between using ::before and ::after?
13Can pseudo-elements be positioned using CSS positioning properties? Can pseudo-elements have background images or colors? How can you use pseudo-elements to create shapes or icons?
14Can you use multiple pseudo-elements on the same element?
15What is the ::selection pseudo-element used for?
16How does stacking and z-index affect pseudo-elements?
17Can pseudo-elements have child elements or content inside them?
18Can you apply pseudo-elements to replaced elements (like <img>)?
19How do pseudo-elements interact with display and overflow properties?
20What’s the difference between using pseudo-elements and real elements for decoration?
21How does inheritance work with pseudo-elements?
22Can pseudo-elements trigger JavaScript events (like click)?
23How can you control the generated content with pseudo-elements using attr()?
24Can pseudo-elements be used inside flex or grid layouts?
25How do you control the stacking order of ::before and ::after pseudo-elements?
26How can you create a tooltip using pseudo-elements?
27How can you make a custom underline or highlight effect using ::after?
28How can you make a quotation mark appear before a paragraph using pseudo-elements?
29How do you create a triangle or arrow shape using only CSS pseudo-elements?
30How can you use pseudo-elements to add icons without extra markup?
31How can you create a button hover animation using ::before or ::after?
32How can pseudo-elements help in implementing skeleton loaders or shimmer effects?
33How can you use ::before and ::after to clear floats?
34How can you create a border animation using pseudo-elements?
35How can pseudo-elements be used in responsive design?
36What is the ::marker pseudo-element and when is it used?
37What does the ::placeholder pseudo-element do?
38How does ::cue work with media elements?
39What is ::backdrop, and where is it used?
40What is the difference between ::file-selector-button and other input pseudo-elements?
41How does the ::part() pseudo-element work in Web Components?
42How is ::slotted() different from ::part() in shadow DOM styling?
43Can you style text highlights with pseudo-elements?
44How can ::selection be customized for accessibility and branding?
45What are the limitations of pseudo-elements compared to actual DOM elements?
38 / 45

How does ::cue work with media elements?

Understanding the ::cue Pseudo-Element in CSS

The ::cue pseudo-element is used to style WebVTT (Web Video Text Tracks) cues in media elements like <video> or <audio>. It allows you to customize the appearance of subtitles or captions rendered by the browser.

Key Points
  1. 1

    ::cue targets the text of a WebVTT track, such as subtitles or captions.

  2. 2

    You can style properties like color, background, font-size, font-family, text-shadow, and line-height.

  3. 3

    It applies only to text rendered from <track> elements associated with media.

  4. 4

    Multiple ::cue selectors can be combined with conditions, e.g., ::cue(v[lang=en]) for language-specific styling.

Example: Styling Video Subtitles with ::cue

In this example, all subtitles from the WebVTT track are displayed with yellow text on a semi-transparent black background, with a slight text shadow for readability.

Best Practices
  1. 1

    Use ::cue to improve subtitle readability and match your site's design.

  2. 2

    Test styling across different browsers, as some may render cues slightly differently.

  3. 3

    Avoid overly decorative styles that could make subtitles hard to read.

  4. 4

    Combine with accessibility guidelines to ensure subtitles are legible for all users.

Difficulty: 6/10
Topics: CSS pseudo-elements, media player UI customization, shadow DOM styling

Scenario Questions

0-2 years experience
  1. 1

    How would you style the subtitles in a <video> element to be white with a black outline using CSS?

  2. 2

    What happens if you try to use ::cue on a <video> that has no <track> element defined?

2-5 years experience
  1. 1

    Our video player’s captions suddenly stopped responding to ::cue styles after we upgraded the frontend framework — what could be breaking this, and how would you debug it?

  2. 2

    We’re using WebVTT captions, but ::cue styles only work in Chrome — how would you investigate and fix cross-browser inconsistency?

5-8 years experience
  1. 1

    How would you design a themable video player that supports dynamic caption styling via ::cue while maintaining performance on low-end devices?

  2. 2

    You need to support both custom ::cue styles and user-selected accessibility presets — how do you avoid CSS specificity conflicts and ensure the user’s choice always overrides defaults?

8+ years experience
  1. 1

    We’re migrating from a custom caption overlay system to native <track> + ::cue — what architectural tradeoffs do you consider around accessibility, performance, and legacy browser support?

  2. 2

    How would you design a cross-team standard for media caption styling that ensures consistency across 20+ products while allowing product teams to customize appearance without breaking accessibility compliance?

Follow-up Questions

  • What happens if you apply a margin to ::cue and it doesn’t render?
  • How would you debug why captions aren’t styling even though the CSS rule looks correct?
  • Can ::cue style multiple text tracks at once, or do you need separate rules?