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.
Fundamentals
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.
Foundation
📝 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.
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;}}
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.
Compatibility
🖥 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 featureExperimental
Bottom line: Learn the syntax now, but rely on solid defaults and prefers-color-scheme for production. Revisit as browser support grows.
Wrap Up
🎉 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.
Use these points when exploring environment-based CSS.
5
Core concepts
N01
normal
Typical light.
Default
D02
dim
Dark room.
Value
W03
washed
Bright glare.
Value
S04
Sensors
Ambient lux.
Hardware
Exp05
<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.