Water heaters work by using either gas or electricity to heat a tank full of water that is then distributed to taps throughout the house. A thermostat on the outside of the water heater allows the user to adjust the temperature of the water in the heater.
Water heater tanks are designed with two layers. The inner tank holds the water, while a small chamber between the inner tank and the outside wall holds the heating element. Water enters the heater through a dip tube at the top of the tank. It flows directly to the bottom of the tank, where it's heated by a gas burner (in a gas water heater) or wire filaments (in an electric water heater). Hot water naturally rises to the top of the tank, where it exits the tank by way of the heat-out pipe.
Heaters are also designed with several safety features. A pressure-relief valve found on the side of the tank allows the user to monitor the water pressure inside the tank and automatically reduce it if it gets dangerously high. A tap located near the bottom of the tank, called the drain cock, allows the water to be drained from the tank for cleaning.