Science behind candles?

The wax in a candle turns to liquid as heat is supplied to it by the flame.The wax goes up the wick by capillary action and turns into vapour and than burns to form CO2 vapour and heat and light..