CSS light-level Media Feature

Beginner
⏱️ 6 min read
📚 Updated: Jul 2026
🎯 4 Examples
Media Queries

What You’ll Learn

The light-level media feature adapts styles to ambient lighting — dim rooms, normal indoor light, or bright glare. Learn the syntax and when it makes sense to use this experimental feature.

01

@media

Media query.

02

normal

Typical light.

03

dim

Dark room.

04

washed

Bright glare.

05

Sensors

Ambient light.

06

Fallback

Experimental.

Introduction

Some devices have ambient light sensors that measure how bright the surroundings are. The @media (light-level) feature lets CSS respond to that reading — dimming the UI in a dark room or softening glare in direct sunlight.

This is different from the user choosing dark mode. Light-level reacts to the physical environment, which can change as the user moves outdoors, enters a cinema, or turns off room lights.

Definition and Usage

Write @media (light-level: dim), @media (light-level: normal), or @media (light-level: washed) to target each lighting condition. Always provide default styles for devices without light sensors.

💡
Beginner Tip

light-level is largely experimental with minimal browser support today. Learn the concept for future-ready CSS, but use prefers-color-scheme and strong default contrast for production sites.

📝 Syntax

Use one of three keywords inside an @media rule:

syntax.css
@media (light-level: normal) {
  /* Typical indoor lighting */
}

@media (light-level: dim) {
  /* Low ambient light — dark room */
}

@media (light-level: washed) {
  /* Very bright — glare, direct sunlight */
}

Accepted Values

  • normal — Typical lighting; neither unusually dark nor excessively bright (default for most environments).
  • dim — Low ambient light; increase contrast and consider darker backgrounds to reduce eye strain.
  • washed — Very high ambient light; soften harsh whites and reduce glare for outdoor or sunny conditions.

Three Lighting Conditions

normal Office or home indoor lighting. Standard contrast works well.
dim Dark room, night, cinema. Boost contrast; darker UI reduces glare.
washed Direct sun on screen. Soften bright whites; avoid harsh pure #fff backgrounds.

light-level vs prefers-color-scheme

(light-level: dim) Hardware sensor detects low ambient light in the physical environment.
(prefers-color-scheme: dark) User preference for a dark theme in OS settings — independent of room lighting.

Basic Example

light-level-basic.css
body {
  background-color: #fff;
  color: #1e293b;
}

@media (light-level: dim) {
  body {
    background-color: #1e293b;
    color: #f8fafc;
  }
}

@media (light-level: washed) {
  body {
    background-color: #e2e8f0;
    color: #334155;
  }
}

Default Value

When no sensor is available, browsers typically treat the environment as normal. Your base CSS should work without any light-level rules.

Syntax Rules

  • One keyword per query: (light-level: dim).
  • Always define readable defaults outside media queries.
  • Treat as progressive enhancement — most browsers won’t match today.
  • Combine with prefers-color-scheme for broader theme support.
  • Do not rely on light-level for critical accessibility alone.

Related Topics

@media (light-level: dim) @media (light-level: normal) @media (light-level: washed)

⚡ Quick Reference

QuestionAnswer
Feature namelight-level
Valuesnormal, dim, washed
What it detectsAmbient light via device sensors
Dim environmentIncrease contrast; darker UI
Washed environmentSoften whites; reduce glare
Production useProgressive enhancement only
Browser supportExperimental — minimal support

When to Use light-level

Reach for light-level when ambient lighting affects readability:

  • Future-ready designs — Prepare for devices with ambient light sensors.
  • Outdoor apps — Soften UI in washed (sunny) conditions.
  • Night reading — Darker, higher-contrast UI in dim environments.
  • Kiosk / field devices — Hardware that moves between indoor and outdoor light.
  • Learning media queries — Understand environment-based responsive design.

👀 Live Preview

Most browsers show the default normal styling below. On supported devices with ambient sensors, dim or washed rules would apply automatically:

Light Level Demo Default: normal lighting (white background)

Visual reference for all three values:

normalWhite bg
dimDark bg
washedSoft gray bg

Examples Gallery

Practice light-level with background themes, dim-mode contrast, washed-mode glare reduction, and fallback patterns.

📜 Core Patterns

Adapt page colors to ambient lighting conditions.

Example 1 — Background by light level

Change page background for normal, dim, and washed environments:

light-level-theme.css
@media (light-level: normal) {
  body {
    background-color: #fff;
    color: #1e293b;
  }
}

@media (light-level: dim) {
  body {
    background-color: #1e293b;
    color: #f8fafc;
  }
}

@media (light-level: washed) {
  body {
    background-color: #e2e8f0;
    color: #334155;
  }
}
Try It Yourself

How It Works

This is the classic pattern from the reference tutorial — three environment-aware color themes.

Example 2 — Boost contrast in dim light

Increase font weight and contrast when ambient light is low:

light-level-dim.css
.article {
  padding: 1.5rem;
  line-height: 1.6;
}

@media (light-level: dim) {
  .article {
    background: #0f172a;
    color: #f1f5f9;
    font-weight: 500;
  }
  .article a {
    color: #93c5fd;
    text-decoration: underline;
  }
}
Try It Yourself

How It Works

In low light, bright screens glare. A darker UI with bolder text is easier on the eyes.

Example 3 — Reduce glare in washed light

Soften pure white backgrounds and heavy shadows in bright outdoor conditions:

light-level-washed.css
.card {
  padding: 1rem;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  border-radius: 0.5rem;
}

@media (light-level: washed) {
  .card {
    background: #e2e8f0;
    box-shadow: none;
    border: 1px solid #94a3b8;
  }
}
Try It Yourself

How It Works

Pure white cards reflect sunlight and create glare. Muted backgrounds and borders stay readable outdoors.

Example 4 — light-level with prefers-color-scheme fallback

Use color-scheme for broad support; layer light-level when sensors are available:

light-level-fallback.css
/* Broad fallback — user dark mode preference */
@media (prefers-color-scheme: dark) {
  body {
    background: #1e293b;
    color: #f1f5f9;
  }
}

/* Experimental — physical dim environment */
@media (light-level: dim) {
  body {
    background: #0f172a;
  }
}

@media (light-level: washed) {
  body {
    background: #cbd5e1;
    color: #1e293b;
  }
}
Try It Yourself

How It Works

Ship with color-scheme first. Light-level adds environment-aware refinement on capable hardware.

💬 Usage Tips

  • Defaults first — Base styles must work without any light-level match.
  • Layer with color-scheme — Use both for preference and environment.
  • Dim = darker UI — Reduce screen brightness perception with dark backgrounds.
  • Washed = softer UI — Avoid pure #fff and heavy shadows outdoors.
  • Monitor spec changes — Experimental features evolve; recheck MDN periodically.

⚠️ Common Pitfalls

  • Assuming browser support — Very few browsers implement light-level today.
  • Confusing with dark mode — User preference ≠ ambient sensor reading.
  • Requiring sensors — Never make core UX depend on light-level.
  • Over-darkening in dim — Still maintain WCAG contrast ratios.
  • Ignoring fallbacks — Always ship readable default styles.

♿ Accessibility

  • WCAG contrast — Meet 4.5:1 text contrast in all light levels.
  • User control — Don’t override explicit theme preferences without reason.
  • Photosensitivity — Avoid flashing between themes on sensor changes.
  • Baseline readability — Good defaults help users without sensors.
  • Test manually — Simulate dim/washed styles in DevTools for review.

🧠 How light-level Works

1

Sensor reads ambient light

The device measures surrounding brightness (lux level).

Sense
2

Browser maps to a value

The reading becomes normal, dim, or washed.

Map
3

@media rules apply

Matching CSS adjusts contrast, backgrounds, and glare reduction.

Apply
=

Environment-aware UI

Content adapts to the room or outdoor lighting around the user.

🖥 Browser Compatibility

The light-level media feature is experimental with minimal real-world browser support. Treat it as future-facing progressive enhancement.

Experimental · Limited support

Ambient light queries

Not production-ready. Use prefers-color-scheme for theme support today.

<5% Global support
light-level media feature Experimental

Bottom line: Learn the syntax now, but rely on solid defaults and prefers-color-scheme for production. Revisit as browser support grows.

🎉 Conclusion

The light-level media feature adapts CSS to ambient lighting with normal, dim, and washed values. It is a forward-looking tool for environment-aware responsive design.

While experimental today, understanding light-level prepares you for sensor-equipped devices. Always ship readable defaults and use prefers-color-scheme for broad theme support in the meantime.

💡 Best Practices

✅ Do

  • Ship strong defaults
  • Use prefers-color-scheme
  • Darken UI in dim
  • Soften UI in washed
  • Treat as enhancement

❌ Don’t

  • Require sensor support
  • Confuse with dark mode
  • Use pure white outdoors
  • Skip contrast checks
  • Depend on it in production

Key Takeaways

Knowledge Unlocked

Five things to remember about light-level

Use these points when exploring environment-based CSS.

5
Core concepts
D 02

dim

Dark room.

Value
W 03

washed

Bright glare.

Value
S 04

Sensors

Ambient lux.

Hardware
Exp 05

<5% support

Future CSS.

Compat

❓ Frequently Asked Questions

The light-level media feature detects ambient light around the user via device sensors. Use @media (light-level: dim), (light-level: normal), or (light-level: washed) to adapt contrast and colors for dark rooms, typical lighting, or very bright environments like direct sunlight.
Three values: normal (typical indoor lighting), dim (low ambient light — dark room), and washed (very bright ambient light — glare conditions such as direct sunlight on the screen).
No. Dark mode uses prefers-color-scheme: dark based on user preference. light-level uses hardware ambient light sensors to detect the physical environment. They solve different problems and can be combined.
Browser support is very limited and the feature is largely experimental. Treat it as progressive enhancement with solid default styles. Rely on prefers-color-scheme and good baseline contrast for production sites.
In dim light, increase contrast and use darker backgrounds with lighter text to reduce eye strain. In washed (very bright) light, soften harsh whites, reduce glare, and avoid ultra-thin font weights.

Practice in the Live Editor

Open the HTML editor and experiment with @media (light-level: dim) environment-aware styles.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful