We interpret the (conjectural) product formula for periods of abelian varieties with complex multiplication in terms of heights. The verification of this formula for the periods of the Fermat curves allows us to give a geometric proof of the Chowla-Selberg formula.