Skip to main content

HTML Guide

Bad value X for attribute “media” on element “link”: Parse Error.

The media attribute on a <link> element specifies the media for which the linked resource is intended, using a valid media query. The value indicated is not a valid media query, which leads to a parse error.

Explanation

The media attribute is used to define what type of device the linked stylesheet should be applied to. Examples include common media types like screen, print, or all, as well as more complex media queries, such as (max-width: 600px) for responsive designs.

Correct Usage

  1. Media Type Only:

    You can specify general media types such as screen, print, or all.

    <link rel="stylesheet" href="styles.css" media="screen">
  2. Media Query:

    For more precise control, use a media query to target specific conditions.

    <link rel="stylesheet" href="styles.css" media="(max-width: 600px)">

Learn more:

Related W3C validator issues