A stalactite is formed by rain water falls through the air, and it picks up carbon dioxide. As the water soaks through the soil, it picks up more carbon dioxide which is being given off by decaying vegetation in the soil. Water and carbon dioxide form a mild acid, carbonic acid, which is similar to the fizz in a coke. As this acid seeps through limestone it dissolves the calcium carbonate out of the limestone. This dissolved mineral is dripped into the cave, where the carbon dioxide is given off. The water will no longer carry the minerals, so they are deposited in the shape of tiny crystals. These crystals are known as calcite, or cave onyx. Sometimes calcite is deposited as the drips hanging from the ceiling of the cave, forming a stalactite.

Image courtesy of http://www.dgl.microsoft.com