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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing two different stylesheets on the same page

Status
Not open for further replies.

BobAmsk

Programmer
Oct 24, 2001
2
US
Is it possible to draw from two different stylesheets on the same HTML page? Specifically, I am looking for a local tag to override the stylesheet referenced at the top of my code.
 
It appears that styles defined in a CSS are order dependant. For example, the following code would render the "Hello" text in the browser in Verdana, bold.

Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--

//-->
</script>
<style>
body {
     font-family: Verdana;
     font-weight: bold;
     }
</style>
</head>
<body>
Hello
</body>
</html>

While the following code would render the &quot;Hello&quot; in Times, Bold.

Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--

//-->
</script>
<style>
body {
     font-family: Verdana;
     font-weight: bold;
     }
body {
     font-family: Times;
     }
</style>
</head>
<body>
Hello
</body>
</html>

And again, the following page would render the hello in Arial.
Code:
<html>
<head>
<script Language=&quot;JavaScript&quot;>
<!--

//-->
</script>
<style>
body {
     font-family: Verdana;
     font-weight: bold;
     }
body {
     font-family: Times;
     }
</style>
</head>
<body>
<font face=&quot;Arial&quot;>Hello</font>
</body>
</html>

Does that help ??

ToddWW
 
Thanks, Todd. I still have a little bit more to go, though.

My site is going to have thousands and thousands of pieces of content that are written from the page straight from the database. Each page will have a stylesheet that it links to in the header <link href=orange.css> and I need to know if I can throw elements into the page that will look to a separate stylesheet <link href=blue.css> while the rest of the page still uses the original stylesheet. I'm beginning to think it's not possible.
 
I don't think so. Not in the way you are envisioning it. You could setup classes in your second style sheet, reference it in the head of the document along with the first, then set the class for the elements that you want to take on the styles in the 2nd sheet.

Does that make sense ??

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top