YogeshChauhan . com

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.

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

amazon

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 How to Use SQL MAX() Function with Dates? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Jun 16 What are Stored Procedures for SQL Server? Jun 16 What are Class Constants in PHP? Jun 15 A short basic guide on states in React Jun 15 How to define constants in PHP? Jun 15 How to define visibility for a property in PHP? Jun 15 How to use @if and @else in SCSS?

You might also like these

How to switch dark and light themes using pure CSS?CSSCreate a simple bar chart and column chart using pure CSS gridCSSThe fundamental difference between HAVING and WHERE clauses in PostgresPostgresSELF JOIN in PostgresPostgresHow to check if checkbox is checked or not using JavaScript?JavaScriptHow to display and animate image on scroll using JavaScript?JavaScript