Image from unsplash

I happened to use an input-label association for creating a toggle switch. Though I earlier read about the strong bonding between them but hadn’t yet come across something.

The first set of images shows CSS and input and HTML as siblings, hence style is applied with an adjacent selector.

The second set of images shows a changed selector as input is moved inside the label, called the general sibling selector.

--

--

Only very recently did I become aware of the onClick event of a div element. Have always used the onClick on a “button” for triggering DOM manipulations and state changes. The onClick listener on div’s is very simple to understand yet not so commonly seen.

--

--