Implementing CSS based on any media query expression may not align with the specified guidelines for the media
attribute.
For a list of acceptable values for the media
attribute, refer to this resource:
https://www.w3schools.com/tags/att_link_media.asp
The allowed values for the media attribute are limited to specific ones such as: width
, color
, orientation
, among others. Refer to the tables in the link provided above for more details.
It is considered best practice to load all CSS, including media queries, directly rather than separately. Loading all styles at once during the initial phase allows the browser to have everything in memory and render elements swiftly.
Loading each media query individually would require the browser to determine which CSS file to request from the server when, for example, the user rotates their tablet. This could lead to delays and cause jittery movements on the page, significantly impacting user experience.
Although loading extra kilobytes for media queries CSS might seem like an issue, consolidating all styles into a few files offers benefits:
- Reduces the number of TCP connections that need to be established
- Enhances efficiency in compression during data transmission
- If the styles remain unchanged, they can be cached by the browser and requested only once