Yogesh Chauhan's Blog

Alternate Style Sheets in CSS

in CSS on 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.


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.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
WordPress: How to print ACF repeater field values?WordPressVariables scope and shadowing in SCSS (Sass)SCSSHow to convert a number rounding to a specified number of decimals in JavaScript?JavaScriptsubstring() Method in JavaScriptJavaScriptAlways add associated labels to your Form elementsUI/UXShort-Circuit Evaluation in JavaScriptJavaScript