JavaScript Screen mozBrightness Property

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
🚀 5 Try-it labs
Deprecated
Non-standard
Instance property

What You’ll Learn

Screen.mozBrightness is a deprecated, non-standard instance property that described how bright the screen backlight was on a scale from 0 (very dim) to 1 (full brightness). Learn the scale, the write/read precision caveat, how to feature-detect safely, and why modern pages should not control hardware brightness—with five examples and try-it labs.

01

Kind

Instance property

02

Returns

Number (0–1)

03

Status

Deprecated · Non-standard

04

Access

window.screen

05

Engine

Mozilla legacy

06

Spec

None

Introduction

Long ago, some Mozilla environments (including Firefox OS era APIs) exposed a way for privileged pages to read or set the screen backlight. That property was screen.mozBrightness: a floating-point number between 0 and 1.

Today it is a historical footnote. Most modern desktop and mobile browsers do not expose a webpage-controlled backlight API. This tutorial teaches the old property so you can understand legacy snippets—and avoid shipping new ones.

JavaScript
console.log(window.screen.mozBrightness);
💡
Beginner tip

On Chrome, Safari, Edge, and modern Firefox builds you will usually see undefined. That is expected. Always feature-detect; never assume the property exists.

Understanding the Property

MDN: mozBrightness indicates how bright the screen’s backlight is, on a scale from 0 (very dim) to 1 (full brightness). The value is a double-precision float.

  • Instance — on window.screen where supported.
  • Historically read/write — not a modern cross-browser API.
  • Range — conceptually 01.
  • Deprecated & Non-standard — not in any specification.

📝 Syntax

JavaScript
// Read (legacy only)
const level = window.screen.mozBrightness;

// Write (legacy only — do not use in new apps)
// window.screen.mozBrightness = 0.75;

Value

A number from about 0 to 1. MDN notes you could read and write even when the screen was disabled, but the backlight stays off while the screen is disabled. Writing X may not round-trip to the same X when you read again—hardware has fewer brightness steps than floating-point values.

⚠️ Write vs Read Precision

MDN’s important teaching point: if you write a value into mozBrightness, a later read may return a nearby quantized value. Think of it like setting a dimmer that only has a few notches—you ask for 0.73, the device stores something closer to 0.75.

JavaScript
// Legacy idea only — skipped when unsupported
if ("mozBrightness" in screen) {
  screen.mozBrightness = 0.73;
  console.log(screen.mozBrightness); // may not be exactly 0.73
}

🎯 What To Do Instead

GoalModern approach
User comfort / eye strainOS night light, auto-brightness, system settings
Page looks darkerCSS themes, filter / opacity on content (not hardware)
Legacy Firefox OS codeRemove mozBrightness; do not port to the open web
Screen size metricsStandard screen.height, availHeight, etc.
🔒
Privacy & platform tip

Controlling the physical backlight from a random website would be surprising and invasive. Modern browsers intentionally keep that power with the OS and the user.

🛡️ Feature Detection Pattern

Wrap every access. Unsupported browsers should log a clear message and skip writes.

JavaScript
function getMozBrightness() {
  if (!("mozBrightness" in window.screen)) {
    return { supported: false, value: null };
  }
  return { supported: true, value: Number(window.screen.mozBrightness) };
}

console.log(getMozBrightness());

⚡ Quick Reference

GoalCode / note
Feature-detect"mozBrightness" in screen
Read (legacy)screen.mozBrightness
Scale0 = dim … 1 = full
Round-tripWritten value may not equal later read
MDN statusDeprecated · Non-standard
New codeDo not use

🔍 At a Glance

Four facts about screen.mozBrightness.

Kind
property

Legacy r/w

Type
number

0 to 1

Via
window.screen

When present

Status
deprecated

Non-standard

Examples Gallery

Examples follow MDN Screen.mozBrightness. On modern browsers the demos print “not supported”—that is the correct teaching outcome.

📚 Getting Started

Detect support and read safely without throwing.

Example 1 — Feature-Detect mozBrightness

Check whether the property exists on screen.

JavaScript
if ("mozBrightness" in window.screen) {
  console.log("mozBrightness is present (legacy)");
  console.log(typeof screen.mozBrightness);
} else {
  console.log("mozBrightness not supported");
}
Try It Yourself

How It Works

The in operator is the safest first step. Most modern engines take the else branch.

Example 2 — Safe Read with Fallback

Return the number only when supported.

JavaScript
function readMozBrightness() {
  if (!("mozBrightness" in screen)) {
    return "(unsupported)";
  }
  return screen.mozBrightness;
}

console.log(readMozBrightness());
console.log(typeof screen.mozBrightness);
Try It Yourself

How It Works

Helpers keep demos readable and avoid treating undefined as a brightness level.

📈 Labels, Clamping & Snapshots

Explain the 0–1 scale and combine with baseline Screen metrics.

Example 3 — Percent Label for 0–1 Scale

Map a supported value to a beginner-friendly percent string.

JavaScript
function labelMozBrightness() {
  if (!("mozBrightness" in screen)) {
    return "unsupported (do not use in new apps)";
  }
  const pct = Math.round(Number(screen.mozBrightness) * 100);
  return pct + "% backlight (legacy)";
}

console.log(labelMozBrightness());
Try It Yourself

How It Works

Multiplying by 100 turns 0.75 into “75%” for teaching. Still skip this path when the API is missing.

Example 4 — Clamp Idea Before a Legacy Write

Show how you would clamp to 0–1 if the API existed (demo does not write).

JavaScript
function clamp01(n) {
  return Math.min(1, Math.max(0, Number(n)));
}

const wanted = clamp01(1.4); // becomes 1
console.log("would request:", wanted);

if ("mozBrightness" in screen) {
  // Legacy only — avoid in new apps:
  // screen.mozBrightness = wanted;
  console.log("API present; write skipped in this tutorial demo");
} else {
  console.log("API missing; no write attempted");
}
Try It Yourself

How It Works

Clamping teaches the documented range without changing the user’s display. The demo intentionally does not assign to mozBrightness.

Example 5 — Legacy Flag Plus Standard Screen Snapshot

Show support status next to baseline Screen metrics.

JavaScript
console.log({
  mozBrightness: "mozBrightness" in screen
    ? screen.mozBrightness
    : "(unsupported — deprecated & non-standard)",
  width: screen.width,
  height: screen.height,
  availHeight: screen.availHeight,
  colorDepth: screen.colorDepth
});
Try It Yourself

How It Works

Contrast the legacy flag with standard properties like height and colorDepth that you should use today.

🚀 Common Use Cases

  • Reading / migrating old Firefox OS or Mozilla-privileged code.
  • Interview or tutorial context: “why can’t websites set backlight?”
  • Feature-detection drills for moz* prefixed APIs.
  • Auditing a codebase for deprecated Screen properties to remove.
  • Teaching the difference between CSS visual brightness and hardware backlight.

🔧 How It Works

1

Device has a backlight

OS controls brightness with limited hardware steps.

Hardware
2

Legacy Mozilla exposed mozBrightness

0–1 float mapped onto those steps (non-standard).

Legacy API
3

Modern browsers omit it

Property missing; feature-detect returns unsupported.

Today
4

Leave brightness to the OS

Use standard Screen size/color metrics for diagnostics instead.

📝 Notes

  • Deprecated and Non-standard (MDN)—both banners shown above.
  • Not Experimental on MDN.
  • Not part of any specification.
  • Written values may not round-trip exactly when the API existed.
  • Related: isExtended, height, Window hub, JavaScript hub.

Legacy / Deprecated Support

Screen.mozBrightness is Deprecated and Non-standard. It is not part of any specification and is missing or removed in modern browsers. Logos use the shared browser-image-sprite.png sprite from this project. Do not rely on it for production.

Deprecated · Non-standard

Screen.mozBrightness

Legacy 0–1 backlight brightness — Mozilla-oriented, not for new web apps.

Legacy Avoid in new apps
Mozilla Firefox Legacy / typically removed or unavailable in modern builds
Avoid
Google Chrome Not supported — feature-detect
Unavailable
Microsoft Edge Not supported — feature-detect
Unavailable
Apple Safari Not supported — feature-detect
Unavailable
Opera Not supported — feature-detect
Unavailable
Internet Explorer No mozBrightness support
Unavailable
mozBrightness Deprecated

Bottom line: Feature-detect only for legacy literacy. Never require mozBrightness. Leave hardware brightness to the OS; use standard Screen metrics for size and color depth.

Conclusion

window.screen.mozBrightness was a deprecated, non-standard 0–1 backlight level for Mozilla environments. Feature-detect if you meet it in old code, expect it to be missing today, and never build new products around webpage-controlled hardware brightness.

Continue with mozEnabled, isExtended, Window methods, or the JavaScript hub.

💡 Best Practices

✅ Do

  • Feature-detect with "mozBrightness" in screen
  • Treat missing support as normal on modern browsers
  • Remove the property from any codebase you maintain
  • Use OS settings for real brightness changes
  • Prefer standard Screen size / color properties for diagnostics

❌ Don’t

  • Use mozBrightness in new production apps
  • Assume a written value round-trips exactly
  • Confuse CSS filter: brightness() with hardware backlight
  • Require backlight control for core product flows
  • Skip reading MDN’s Deprecated and Non-standard warnings

Key Takeaways

Knowledge Unlocked

Five things to remember about mozBrightness

Deprecated non-standard backlight float.

5
Core concepts
⚠️ 02

Deprecated

avoid in new code

Status
🚫 03

Non-standard

no public spec

Spec
🛡️ 04

Detect first

usually missing

Safety
🎯 05

Use OS

not the webpage

Modern

❓ Frequently Asked Questions

On engines that still expose it, a number from 0 (very dim) to 1 (full brightness) describing the screen backlight. Access was typically window.screen.mozBrightness.
MDN marks Screen.mozBrightness as Deprecated and Non-standard. It is not Experimental. Do not use it in new code.
Historically yes—you could read and write it. MDN notes you may write X and later read a different value because most screens support fewer brightness steps than doubles between 0 and 1.
No. It is a Mozilla-specific, non-standard property and is missing or removed in modern browsers. Always feature-detect; expect undefined elsewhere.
There is no standard web API for controlling the device backlight from a normal webpage (for privacy and platform reasons). Leave brightness to the OS/user, or use CSS filters only for on-page visuals—not hardware backlight.
Helpful for reading legacy Firefox / Firefox OS code and interviews. Feature-detect, never require it, and migrate away from brightness control in the page.
Did you know?

The moz prefix signals a Mozilla experiment or proprietary extension. Many historical moz* APIs were never standardized. When you see the prefix in old docs, assume limited support and look for a standard successor—or no web successor at all, as with backlight control.

Next: Screen.mozEnabled

Learn the deprecated non-standard screen on/off boolean.

mozEnabled →

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