Toggle switch or On OFF Switch is beneficial in updating preferences, settings and different type of information. It is more specifically used when the user decides between two opposing situations.
In this lesson you will learn to create a toggle switch using simple and minimal HTML and CSS code.
Foremostly, create a design layout, for this example, a rounded switch layout will be designed. A single section is created which includes input type, and span.
The base for the switch is designed where the user-select property is assigned with value none to prevent the selection of text on double-clicking it. In order to control the display of the default callout shown when somebody touches or holds the touch target, WebKit-touch-callout is given a value none. Using before and after selector OFF and ON sections are designed. Use the below code to make your site interactive.
The end result of applying the specified HTML and CSS code is here.