CSS Examples Alternate Style Sheet for document
Author: CSS Drive
You can specify an alternate style sheet for a document in CSS. For browsers that support it (such as Firefox 1.0+), the user is then able to easily toggle between the main style sheet and alternative one via an icon image located typically in the lower left or right of the browser window:
The CSS:
<LINK type="text/css" rel="stylesheet" href="main.css" title="Default Style" />
<LINK type="text/css" rel="alternate stylesheet" href="alternate.css" title="Alternate Style" />
The second style sheet is an alternate one. The key is to set to "rel" attribute to "alternate stylesheet." The "title" attribute is also important, providing a name for the style sheet while also allowing you to group multiple external style sheets together (all those that share the same "title"), to be applied to the document simultaneously.
Comments (21)
I like it!
this is a very handy tool but i does anyone know how you can change it from one style sheet to another by way of a button from within the website and not through the browser? im new to css but can anyone share a link on that? thanks! much appreciated
cool,useful, really thanks
Hi Hayek,
Yes you can change style sheets with a button, it does however require using javascript. Here is a function that should do it for you, I ripped it from the following site:
http://www.alistapart.com/stories/alternate/
function setActiveStyleSheet(title) {
var i, a, main;
for(i=0; (a = document.getElementsByTagName("link")); i++) {
if(a.getAttribute("rel").indexOf("style") != -1
&& a.getAttribute("title")) {
a.disabled = true;
if(a.getAttribute("title") == title) a.disabled = false;
}
}
}
Jereme Guenther
CSS "Cascading Style Sheets" LessoNs - WeB DesigN LessoN - - Web site : http://WWW.css-lessons.ucoz.com/index.html
Great post. I should try on my own.Thanks for posting.
http://vacationrentalhotspots.com/florida/daytona-beach-vacation-rentals.php
CSS TEXT examples , Properties , Attribute -
http://css-lessons.ucoz.com/css-text-properties.htm
Thank you for the information.Very useful.
http://vacationrentalhotspots.com/florida-keys-vacation-rentals