Wiring a Switch with Light in Middle of Circuit
Many times when wiring the circuit will pass through the light's box. But the object in creating a switch is to actually isolate part of a circuit. In the case of our diagram, the ciruit passes through the light box, but the light itself is controlled by the switch even while the circuit passes through to an outlet that is not controlled by the switch.
The source brings in the power from the main box. The black wire from the source is connected to the black wire from the outlet and also to the white wire (marked black) leading to the bottom connector on the switch. The white wire, marked black with tape or paint indicates that it is a "hot" wire. Remember that the black wires are the ones that carry the current. In this case both wires going to and from the switch carry a current. The current is carried into the bottom connector on the switch and then out the top connector and from there to the light.
The white wires from the source, light and the outlet are all connected. The ground wires are all brought together under one cap as well. The ground wire may be connected to the light box as well as the switch box if they are metal. Don't forget when working on electrical circuits to shut off the power at the source.