Caves can be formed by lava (lava tubes), by the crashing of the tides, or by the trickling erosion of slightly acidic water. The way a cave forms tells you a lot about what you'd find inside it. When it comes to writing caves, having a good grasp of how it was created tells you how to describe it, what features it's likely to have, whether water can be found there and what types of creatures might inhabit it.
Solution caves are the most recognizable type of cave. They're found in areas of karst, which is a type of terrain marked by sinkholes, caves, underground streams and other "solution features." Solution features are those caused when water mixes with carbon dioxide or sulfuric acid in the environment and dissolves through soluble minerals like dolomite, limestone or gypsum. It's this dissolution of minerals which leads to the cave formations with which most people are familiar.
Water trickles into the soil where it acquires carbonic acid and continues down into the stone beneath. The acidic water drips along stone, dissolving minerals from the rock. The minerals travel with the water and are then deposited to create formations like stalactites and stalagmites, as well as soda straws, fried eggs and flowstone.
You can find pictures of different types of solution cave formations here.
Solution caves are sometimes cooler, with lower temperatures than the air outside, but it's also possible for them to have higher temperatures. Much higher, such as these caves, which have temperatures so high that they can be fatal with just 15 minutes of exposure. That kind of heat is due to a nearby magma pocket. The humidity is often higher in all caves (it reaches 100% in the above mentioned caves) because solution caves are often wet, contained environments.
The giant crystals in the above cave form through interaction between magma and water. Magma contains anhydrite, which broke down in the (hot) water that flooded those caves and was redeposited over time. More on that here.
Formed by waves as they crash into and eat away at rock, sea caves are often very wide horizontally, but not usually very deep. They reach as far into the rock as the water does. The caves form at a fault in the stone and such faults can create chains of sea caves. If the rock already contains karst caves, they may be opened to the sea by the erosion of waves against the rock, giving the karst cave an outlet into the water.
Sea caves don't usually have formations, although there may be some short stalagmites or flowstone, especially in basalt or sandstone caves. Found all over the world, sea caves are probably the most common type of cave. Inside the cave, the force of the tide is channeled and therefore stronger than it would be outside.
Depending on the tide, the location of the cave and the time of year, sea caves can be wet or dry. Wet caves can sometimes have interesting effects in natural light because the sun is filtered through the water and sometimes takes on the color of the water.
Lava tubes form when the outside lava cools quickly, hardening into a tube while the lava inside remains soft and flows out, emptying the tube somewhat and creating a cave. Cave formations in lava caves include flow ripples, stalactites, stalagmites, lavasicles and splashdowns.
These formations are caused by the movement of lava as it hardens. Flow ripples often look like ripples in a river of black rock. The waves of the lava harden into flow ripples. Splashdowns occur when chunks of the hardened lava ceiling fall into the flowing lava, leaving both ripples in the lava around the splashdowns as well as the chunk of stone itself. Cooling cracks form along the floor, the ceiling or the walls and occur because lava shrinks when it cools.
Anybody got any good links on Lava tubes/caves or sea caves?