CSS Basics – Applying CSS to HTML – @importing Stylesheets
There is one more way of importing external style sheets into HTML files and that is the @import property. The syntax look as given below:
<style type=”text/css” media=”screen”>@import url(“styles.css”);
…other import statements or CSS styles could go here…</style>
Sometimes important statements can be seen without the brackets but it does the same thing. One should also be aware that @import should always be first in an embedded style sheet. And you can specify that the imported style sheet is applied only to certain types of media and that is done by including the media type at the concluding part of the imported statement. However, this works in every browser except IE6 and below.
The code given below does the same thing as the previous example:
<style type=”text/css”>@import url(“styles.css”) screen;
…other import statements or CSS styles could go here…</style>
These are the ways you can import CSS to a HTML document. You may however be careful in choosing the styles you would go with.
Visit back, there are more posts coming up about Cascading Style Sheets i.e. CSS and XHTML.