The grid media feature tests whether the output device uses a grid-based screen (for example a text terminal) instead of a typical bitmap screen.
Most phones and monitors are bitmap devices and match grid: 0. Grid-based examples include text-only terminals and basic phones with one fixed font. This is not a test for CSS Grid layout (display: grid / grid).
Baseline · Widely available.
Not deprecated. Parsed widely; on modern bitmap screens you almost always get grid: 0.
Warning Not CSS Grid detection
To feature-detect CSS Grid layout, use @supports (display: grid). Do not use @media (grid) for that.
Syntax
CSS Syntax
syntax.css
@media (grid:0 | 1) { … }
Boolean form: @media (grid) { … } matches when the value is 1 (grid-based). Always wrap the feature in parentheses.
Do not hide critical UI inside (grid: 1) only. Most users will never hit that branch.
related
Pair with other device queries
For terminals and specialty screens, also consider monochrome, color, and scan.
Compatibility
Browser Support
grid is a browser media feature for device screen type. Node.js, Deno, and Bun do not evaluate it.
✓ Baseline · Widely available
grid
Widely available across modern browsers for many years. On everyday bitmap hardware the matched value is almost always 0.
97%Global support
Google Chrome29+
Full support
Mozilla Firefox8+
Full support
Apple Safari6+
Full support
Microsoft Edge12+
Full support
Opera16+
Full support
Samsung Internet2+
Full support
Internet Explorer10+
Full support
@media (grid)Widely supported
Bottom line: Safe to parse everywhere. Expect grid: 0 on phones and PCs. It is not a JavaScript runtime API and not a CSS Grid layout detector.
Remember
Key Takeaways
Role: detect grid-based vs bitmap output devices.
Values:0 (bitmap) and 1 (grid-based).
Not layout Grid. Use @supports (display: grid) for CSS Grid.
Practice: defaults for bitmap; optional tweaks for grid: 1.
One line:@media (grid: 0|1) asks about the screen type, not whether CSS Grid layout works.
Frequently Asked Questions
It tests whether the output device uses a grid-based screen (such as a text terminal) or a bitmap screen (phones, monitors). Values are 0 for bitmap and 1 for grid-based.
No. The media feature is about the device’s screen type. CSS Grid layout uses properties like display: grid. Do not use this media feature to detect CSS Grid support.
The device is not grid-based — typical bitmap screens. Most laptops, phones, and monitors match (grid: 0).
The device is grid-based, such as text-only terminals or very basic fixed-font phones. Rare on modern consumer hardware.
Use @supports (display: grid) { … }, not @media (grid). The media feature answers a different question.
No. It is a CSS media feature evaluated by the browser layout engine, not a Node.js or server runtime feature.