Matt
Matt

Reputation: 27001

Can one CSS page reference another?

Let's say I have css1.css and css2.css. Just for the sake of keeping files organized and small on my file system / Source control I would like to split them up however in my content, I still want to use all the definitions in both files.

Rather than link reference both in my content page, can css1.css just make css2.css available.

Upvotes: 1

Views: 563

Answers (4)

Henry
Henry

Reputation: 1

I have seen that a lot; the import url("css2.css") feature so it is definitely a way to achieve your objective.

Upvotes: 0

Pablo
Pablo

Reputation: 1069

You can use @import like this in css1.css:

@import url("css2.css");
p { color : #f00; }

Upvotes: 1

bcat
bcat

Reputation: 8941

Assuming both stylesheets are in the same directory, put this code at the top of css1.css.

@import url("css2.css");

Upvotes: 3

David Snabel-Caunt
David Snabel-Caunt

Reputation: 58371

Clearly you can include them all on your page with several nodes, but your best bet is probably a release process script/ant task/automated build process which can concatenate or merge the files based on some manifest or even simply the order of the file names.

You can do other things like compress the css at the same time - automatically optimising files for deployment!

Upvotes: 3

Related Questions