How to Import Style Sheets with @import in CSS

The @import rule in CSS is used to import one style sheet into another.

The following two syntaxes can be used to import style sheets using @import in CSS:

  1. @import "styles.css" mediatypes;
  2. @import url("styles.css") mediatypes;

In these examples, mediatypes would be replaced by a comma-delimited list of media types (all, print, screen, and speech) to which the imported style sheet applies.

In general, we recommend avoiding using @import to import one stylesheet into another because it forces multiple concurrent downloads of separate files (the various CSS stylesheets) and thus can slow down the loading of the page. It is important for you to know that the @import statement exists and how it works.

Author: Chris Minnick

Chris Minnick, the co-founder of WatzThis?, has overseen the development of hundreds of web and mobile projects for customers from small businesses to some of the world’s largest companies. A prolific writer, Chris has authored and co-authored books and articles on a wide range of Internet-related topics including HTML, CSS, mobile apps, e-commerce, e-business, Web design, XML, and application servers. His published books include Adventures in Coding, JavaScript For Kids For Dummies, Writing Computer Code, Coding with JavaScript For Dummies, Beginning HTML5 and CSS3 For Dummies, Webkit For Dummies, CIW E-Commerce Designer Certification Bible, and XHTML.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.