What is the best way to call a CSS file from an HTML file? I am facing many possibilities and have no experience with the best Possible possibilities
1 -
<link rel="stylesheet" media="screen and (max-width: 600px)" href="css/screen600.css">
<link rel="stylesheet" media="screen and (max-height: 400px) and (max-width: 600px)" href="css/screen600x400.css">`
2 -
@media only screen and (max-width: px) {}
In the first example, by adding the media query to your HTML, you will only download the file if it matches that media query
media="screen and (max-width: 600px)". (in your example, some users will download two CSS files, which are are render blocking resource and will delay the page rendering)Placing the media query in the CSS (second example) you will always download that file and then the browser will decide whether to apply those styles or not. So potentially you would be downloading more CSS than you are using.
So there is no single correct answer, but I believe the second approach is the most common because it is easier to maintain.