media attribute in link tag
Robin Kartikeya Khatri

Robin Kartikeya Khatri @robinkartikeyakhatri

About: Hello everyone, this Robin Kartikeya Khatri from India. I am here to learn front end and back end programming.

Location:
India
Joined:
Mar 24, 2020

media attribute in link tag

Publish Date: Dec 12 '20
1 2

Why is media attribute written inside the link tag in html markup? Is it necessary to use media attribute in link tag to create a responsive website? Isn't CSS written using @media (max-width: 1100px) in a CSS file without writing the media attribute? Is it necessary to use @media (max-width: 1100px) in CSS file even after writing media attribute in link tag?

Comments 2 total

  • Pacharapol Withayasakpunt
    Pacharapol WithayasakpuntDec 12, 2020

    I feel like it is equivalent to @media applied to the whole import statement in SCSS.

    It's yet another way to do things without building the CSS first, like it comes from third party CDN.

    I saw it used for

    media="(prefers-color-scheme: dark)" 
    media="(prefers-color-scheme: no-preference), (prefers-color-scheme: light)" 
    
    Enter fullscreen mode Exit fullscreen mode
Add comment