As water seeps through cracks in rock, it dissolves certain compounds; with caves, these compounds are usually calcium carbonate or calcium sulfate. At first, this water creates passages which grow larger over time, forming a cave. Eventually, these voids within the rock grow large enough that the seeping water contacts air, causing its solutes to precipitate. This precipitation may be a function of concentration through water removal (calcium sulfate, calcium carbonate), or through the loss of carbon dioxide (calcium carbonate). Over tens of thousands of years, these drips cause speleothems to form. Formations may be produced on the ceiling, creating pendulous structures called stalactites or structures that "grow" from the floor of the cave upwards, called stalagmites. Stalactites and stalagmites may grow together, given enough time.
Various types of formations develop, depending on whether the water drips, seeps, condenses, flows, or settles into pools. These include:
Most other solution caves that are not in limestone are in gypsum (calcium sulfate), the solubility of which is positively correlated with temperature.Chemistry
Most cave chemistry revolves around calcium carbonate (CaCO3, or limestone), a slightly soluble mineral whose solubility increases with the introduction of carbon dioxide. It is paradoxical in that its solubility decreases as the temperature increases, unlike the vast majority of dissolved solids. This decrease is due to interactions with the carbon dioxide, whose solubility is diminished by elevated temperatures; as the carbon dioxide is released, the calcium carbonate is precipitated.