We combine a semi-analytic model of galaxy evolution with constraints on circumstellar habitable zones and the distribution of terrestrial planets in order to probe the suitability of galaxies of different mass and type to host habitable planets, and how it evolves with time. We find that the fraction of stars with terrestrial planets in their habitable zone (known as habitability) depends only weakly on galaxy mass, with a maximum around 4 × 1010M⊙. We estimate that 0.7% of all stars in Milky Way-type galaxies to host a terrestrial planet within their habitable zone, consistent with the value derived from Kepler observations. On the other hand, th...