Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to have more than one CSS file?

Status
Not open for further replies.

iluvperl

Programmer
Jan 22, 2006
107
Can a page use more than 1 CSS file simultaneuously?

I have a little Perl script I wrote that works as an include as opposed to loading the script directly. I was wondering if it would work to have one CSS for my web site and call a different CSS from within my script. Would that work?

Or are we stuck to just the one CSS file?
 
You can include as many as you want.
Code:
<style type="text/css">
@import url( /path/to/file1.css );
@import url( /path/to/file2.css );
@import url( /path/to/file3.css );
@import url( /path/to/file4.css );
</style>

M. Brooks
 
Or using link syntax would work too. Just know that when the same element is defined in different css files, the last one will be applied:
Code:
<link rel="stylesheet" href="myStyle1.css" type="text/css" />
<link rel="stylesheet" href="myStyle2.css" type="text/css" />
<link rel="stylesheet" href="myStyle3.css" type="text/css" />
 
However, all that multi-stylesheet goodness should happen in the <head> of your document, while I expect your included perl script appears somewhere in the <body>. So if you were hoping to make the script a totally self-contained component you're out of luck, unless you resort to inline styles.

Personally, I wouldn't worry about it. Just stick the styles that apply to the perl output in with your general stylesheet. In fact, it's an advantage - to seperate the markup generated by the script (which is often a pain to change), from the presentation information held in the CSS.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
should happen in the <head> of your document
But you can always bend the rules.
Neven had a problem placing the include within the <body> especially with dynamic content using template objects.

M. Brooks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top