A float switch is a type of level sensor, a device used to detect the level of liquid within a tank. The switch may be used to control a pump, as an indicator, an alarm, or to control other devices.
One type of float switch uses a mercury switch inside a hinged float. Another common type is a float that raises a rod to actuate a microswitch. One pattern uses a reed switch mounted in a tube; a float, containing a magnet, surrounds the tube and is guided by it.  When the float raises the magnet to the reed switch, it closes.  Several reeds can be mounted in the tube for different level indications by one assembly.
A very common application is in sump pumps and condensate pumps where the switch detects the rising level of liquid in the sump or tank and energizes an electrical pump which then pumps liquid out until the level of the liquid has been substantially reduced, at which point the pump is switched off again. Float switches are often adjustable and can include substantial hysteresis. That is, the switch's "turn on" point may be much higher than the "shut off" point. This minimizes the on-off cycling of the associated pump. 
Some float switches contain a two-stage switch. As liquid rises to the trigger point of the first stage, the associated pump is activated. If the liquid continues to rise (perhaps because the pump has failed or its discharge is blocked), the second stage will be triggered. This stage may switch off the source of the liquid being pumped, trigger an alarm, or both.
Where level must be sensed inside a pressurized vessel, often a magnet is used to couple the motion of the float to a switch located outside the pressurized volume. In some cases, a rod through a stuffing box can be used to operate a switch, but this creates high drag and has a potential for leakage. Successful float switch installations minimize the opportunity for accumulation of dirt on the float that would impede its motion. Float switch materials are selected to resist the deleterious effects of corrosive process liquids. In some systems, a properly selected and sized float can be used to sense the interface level between two liquids of different density.