bonaca bonaca - 2 months ago 17
CSS Question

wrong css media syntax

What is wrong here?

<link rel="stylesheet" href='index-02.css'
media="screen and (min-width: 481px and max-width:959px)">


Validating the code on this page I got an error:


Error: Bad value screen and (min-width: 481px and max-width:959px) for attribute media on element link: Expected whitespace or ) but saw a instead.

Answer

Your syntax is slightly off. Each expression needs to be contained within parentheses:

<link rel="stylesheet" href='index-02.css'
      media="screen and (min-width: 481px) and (max-width:959px)">

From the documentation:

Parentheses are required around expressions; failing to use them is an error.

Comments