tags:

views:

13950

answers:

7

Is it possible to include one css file into another?

+57  A: 

YES!

@import url("base.css");
Kevin Read
Huh, has @import always been present in CSS? I thought there wasn't a way to do this.
DGentry
Color me humbled!
Ben Hoffstein
Yes, @import has been there from the beginning on: http://www.w3.org/TR/REC-CSS1.html#the-cascade
Rene Saarsoo
+6  A: 

The CSS @import rule does just that. E.g.,

@import url('/css/common.css');
@import url('/css/colors.css');
Sören Kuklau
+4  A: 

In some cases it is possible using @import "file.css", and most modern browsers should support this, older browsers such as NN4, will go slightly nuts.

Note: the import statement must precede all other declarations in the file, and test it on all your target browsers before using it in production.

seanb
+2  A: 

Yes, use @import

detailed info easily googled for, a good one at http://webdesign.about.com/od/beginningcss/f/css_import_link.htm

DarenW
A: 

Yes.

@import: "your.css";

The rule is documented here.

Gordon Wilson
This syntax is wrong.
bcat
+18  A: 

Yes. Importing CSS file into another CSS file is possible.

It must be the first rule in the style sheet using the @import rule.

@import "mystyle.css";
@import url("mystyle.css");

The only caveat is that older web browsers will not support it. In fact, this is one of the CSS 'hack' to hide CSS styles from older browsers.

Refer to this list for browser support.

Ronnie Liew
+4  A: 

the @import url("base.css"); works fine but bare in mind that every @import statement is a new request to the server. This might not be a problem for you but when optimal performance is required you should avoid the @import.

Gene