Connecting Tech Pros Worldwide Help | Site Map

Linking Style Sheets

Luke Bellamy
Guest
 
Posts: n/a
#1: Jul 20 '05
Hi,
I have been looking for a way to incorperate several different
style sheets into a web page (i.e cascading effect).
I have looked into the @import statement which seems to do what
I want but unfortunately restrictions on the architecture may
this unfeasible. With the LINK tag I could use that but I
understand older browsers dont support it properly.

I will only ever have 2 style sheets. Is there a way to link
one style sheet to another from within itself? For example
I have a master style sheet and if an alternate style sheet
is provided I would like to include the master first (as the default)
at the top in the source of the alternate style sheet. There may be some
funky way out there to do this but couldn't put my finger on
it.

Any suggestions would be appreciated.
Luke Bellamy
Beauregard T. Shagnasty
Guest
 
Posts: n/a
#2: Jul 20 '05

re: Linking Style Sheets


Luke Bellamy pounced upon this pigeonhole and pronounced:[color=blue]
> Hi,
> I have been looking for a way to incorperate several different
> style sheets into a web page (i.e cascading effect).
> I have looked into the @import statement which seems to do what
> I want but unfortunately restrictions on the architecture may
> this unfeasible. With the LINK tag I could use that but I
> understand older browsers dont support it properly.
>
> I will only ever have 2 style sheets. Is there a way to link
> one style sheet to another from within itself? For example
> I have a master style sheet and if an alternate style sheet
> is provided I would like to include the master first (as the default)
> at the top in the source of the alternate style sheet. There may be some
> funky way out there to do this but couldn't put my finger on
> it.[/color]

Call first style sheet from <head>:
<style type="text/css" media="screen, projection">@import
"../style/mymain.css"; </style>

Then from within "mymain.css" :

/* ---------------- The Menu ----------------- */
@import "mymenu.css";
/* ---------------- The Menu ----------------- */

--
-bts
-This space intentionally left blank.
Chris Morris
Guest
 
Posts: n/a
#3: Jul 20 '05

re: Linking Style Sheets


bellamy_luke@hotmail.com (Luke Bellamy) writes:[color=blue]
> I have been looking for a way to incorperate several different
> style sheets into a web page (i.e cascading effect).
> I have looked into the @import statement which seems to do what
> I want but unfortunately restrictions on the architecture may
> this unfeasible. With the LINK tag I could use that but I
> understand older browsers dont support it properly.[/color]

@import will block NS4 and other old browsers, which is presumably
what you mean by 'restrictions on the architecture'.

<link rel="stylesheet" type="text/css" href="style1.css">
<link rel="stylesheet" type="text/css" href="style2.css">
<link rel="stylesheet" type="text/css" href="style3.css">

however seems to load all three properly in every browser I've tested,
including NS4 (not tried IE4 or IE3, which are the only other browsers
I'd imagine being old enough to have a problem with it).
[color=blue]
> I will only ever have 2 style sheets.[/color]

Well, for now...
[color=blue]
> Is there a way to link one style sheet to another from within
> itself? For example I have a master style sheet and if an alternate
> style sheet is provided I would like to include the master first (as
> the default) at the top in the source of the alternate style
> sheet. There may be some funky way out there to do this but couldn't
> put my finger on it.[/color]

You could also use a preprocessor or similar.

--
Chris
Closed Thread