Skip to main content
Validación HTML

CSS: Deprecated media feature “min-device-width”. For guidance, see the Deprecated Media Features section in the current Media Queries specification.

Acerca de este problema HTML

The min-device-width and max-device-width media features were originally designed to query the physical screen dimensions of a device. However, these features have been deprecated in Media Queries Level 4 and Level 5 because they are unreliable in modern browsing contexts. The physical screen size is a poor proxy for the actual available layout space — it doesn’t account for browser chrome, split-screen modes, zoom levels, or the fact that many modern devices report abstract pixel values that don’t correspond to physical hardware pixels in a straightforward way.

The viewport-based alternatives — min-width and max-width — respond to the layout viewport, which is the actual space your content is rendered into. This makes them far more useful for responsive design. When a user zooms in, the layout viewport shrinks, and min-width/max-width queries respond accordingly. With min-device-width, zooming has no effect on the query result, which can lead to layouts that don’t adapt when they should.

Beyond practical concerns, using deprecated features means your CSS may behave inconsistently across browsers in the future, as support could be removed entirely. Validators flag this to encourage migration to the modern, standards-compliant approach.

How to fix it

The fix is a straightforward replacement:

  • min-device-widthmin-width
  • max-device-widthmax-width

If your original query also included the screen keyword solely to pair with device-width targeting, you can safely drop it — min-width and max-width apply across all media types and the screen qualifier is rarely necessary in modern CSS.

If you were using min-device-width to detect high-density or Retina displays (a common pattern in older code), the correct modern approach is to use the resolution media feature instead, such as min-resolution: 2dppx.

Examples

Deprecated usage (triggers warning)

<!doctype html>
<html lang="en">
<head>
  <title>Deprecated media feature</title>
  <style>
    @media screen and (min-device-width: 768px) {
      .sidebar { display: block; }
    }

    @media screen and (max-device-width: 480px) {
      .sidebar { display: none; }
    }
  </style>
</head>
<body>
  <aside class="sidebar">Sidebar content</aside>
</body>
</html>

Both min-device-width and max-device-width are deprecated and will produce validation warnings.

Fixed example using viewport-based queries

<!doctype html>
<html lang="en">
<head>
  <title>Viewport-based media queries</title>
  <style>
    @media (min-width: 768px) {
      .sidebar { display: block; }
    }

    @media (max-width: 480px) {
      .sidebar { display: none; }
    }
  </style>
</head>
<body>
  <aside class="sidebar">Sidebar content</aside>
</body>
</html>

Replacing device-width with resolution for pixel density

Older code sometimes used min-device-width in combination with -webkit-min-device-pixel-ratio to target high-density screens. The modern equivalent uses the resolution media feature:

<!doctype html>
<html lang="en">
<head>
  <title>Resolution media query</title>
  <style>
    /* Deprecated approach */
    /*
    @media screen and (min-device-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
      .hero { background-image: url("hero@2x.jpg"); }
    }
    */

    /* Modern approach */
    @media (min-width: 768px) and (min-resolution: 2dppx) {
      .hero { background-image: url("hero@2x.jpg"); }
    }
  </style>
</head>
<body>
  <div class="hero">Hero section</div>
</body>
</html>

The min-resolution: 2dppx query cleanly replaces vendor-prefixed pixel ratio queries and works alongside the standard min-width viewport query.

Encuentra problemas como este automáticamente

Rocket Validator escanea miles de páginas en segundos, detectando problemas de HTML en todo tu sitio web.

Ayúdanos a mejorar nuestras guías

¿Te ha sido útil esta guía?

¿Listo para validar tus sitios?
Inicia tu prueba gratuita hoy.