This can happen when you remove wall paneling tile wainscot or batten.
Gap between light switch and wall.
Plastic shims are a fast easy solution for backsplash electrical outlets in which the wall box is recessed below tiling quartz granite paneling etc.
Twist the ground wire coming from your light fixture to the ground wire coming from the wall using a clockwise motion.
Look for some oversized cover plates.
Find the right depth for your needs.
In situations where drywall workmanship is sloppier creating a large gap between the electrical box and the drywall or in cases where removal of an old cover plate leaves an old paint line then use of the preferred or even the oversized cover plates work well.
When you add a switch or outlet cover there s a gap between the cover the wall.
I think they invented them just for situations like this.
The minimally expanding foam won t drip down your walls.
If the gap between the electrical box and the drywall is less than 1 4 in fill it with acrylic latex caulk.
Twist the white wire from the light fixture to the white wire coming from the wall using a clockwise motion.
Twist your wire cap on to secure the two wires.
The other is to cover the area with a contact paper and trim the outside to match the edge of the switch plate.
Make sure they are firmly connected.
If you have a switch or receptacle that sits below the surface of the wall just twist apart or fold up and stack these caterpillar spacers to get fine adjustment of your devices light switches receptacles dimmers or any other electrical control.
Typically the standard size is used for new construction where construction tolerances are tighter.