Combine All CSS Media Styles Into Single File

Written on March 26, 2008 – 10:37 am | by Hii Hiong Ching |

As a web designer, we know that we can apply different stylesheets for different media. The following is the most common method used.



The above code requests two separate stylesheets, one for global media styles (screen, print, handheld, tv…) and one for print only. There is nothing wrong with the above, but if load time is an issue you could save yourself a server request by combining your CSS files:

/*  all media  */
@media all
{
    body { color:#666; font:13px arial, helvetica, sans-serif; padding:20px 0 30px 0; }
}  

@media print
{
    body { color:#000; font:12px arial, helvetica, sans-serif; padding:0; }
}

What you need to do is just address each media by using “@media [media] { /* css here */ }”. This method is easier for us to do editing too.

Popularity: 27% [?]

Post a Comment

About Office-it.orG

This is a site to share my knowledge, discovery and experience related to my hobby and work. Most articles on this site are related to web design, web development, graphic design, short reviews, tips and tricks. I sometimes write some about Microsoft Office Application too.

Want to subscribe?

RSS Subscribe in a reader Or, subscribe via email:
Enter your email address:  
Find entries :