YogeshChauhan.com
Alternate Style Sheets in CSS
February 4, 2021

We usually add one stylesheet to out HTML code but an HTML document doesn’t need to have a single style sheet.

We can have a default style for the HTML page and any number of alternatives stylesheets for the reader to choose from.

Why to use it?

It provides few options for users to choose from. Users can select any version of a page, based on their preferences.

The browser decided on which alternatives styles the reader can choose and not every browsers or version of browsers supports it but many of them do.

In Opera and Firefox we can find the styles under the “View” menu. Chrome versions 1-48 don’t support it at all but we can add an extension to it to make it support the alternate stylesheets. Checkout the compatibility report on MDN.

Here is the screen capture from Mozilla.

Alternate stylesheets in Mozilla

To include extra style sheets, we need to add more LINK tags in the header, with the correct REL and TITLE attributes.

Examples

In the example above, the first stylesheet “main.css” will be applied to the HTML page no matter what.

From next 3 listed stylesheets, style_1 will be on the default selected in the browser menu. User can select any stylesheet from those 3 styles.

Sources

dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 4 The substr() method in JavaScript and how it’s different from substring() Mar 4 A complete guide to add responsive YouTube videos using HTML and CSS Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress? Mar 3 substring() Method in JavaScript Mar 3 Window setInterval() Method in JavaScript

You might also like these

How to make WordPress main stylesheet (style.css)?WordPressWhat is Git?MiscHow to get previous days or next days in PHP?PHPWhat’s a Log File and What are Log File Monitors?Misc3 Types of Arrays in PHPPHPHow to read Standard Input in Swift?Swift