How does a toilet tank actually work?
When you flush, a flapper valve at the bottom of the tank opens, letting water rush down into the bowl, which forces waste through the drain by siphon action. As the tank empties, a float (either a ball float or a cup float) drops with the water level. That falling float opens the fill valve, which lets fresh water flow back into the tank through a refill tube. As the water rises, the float rises with it until it reaches the set level and shuts the fill valve off. The flapper meanwhile falls back down and seals the tank once it empties. The whole cycle takes about a minute, and the water level in the tank is what controls everything automatically.