We performed density functional calculations aimed at identifying the atomistic and electronic structure origin of the valence and conduction band, and band gap tunability of halide perovskites ABX(3) upon variations of the monovalent and bivalent cations A and B and the halide anion X. We found that the two key ingredients are the overlap between atomic orbitals of the bivalent cation and the halide anion, and the electronic charge on the metal center. In particular, lower gaps are associated with higher negative antibonding overlap of the states at the valence band maximum (VBM), and higher charge on the bivalent cation in the states at the conduction band minimum (CBM). Both VBM orbital overlap and CBM charge on the metal ion can be tuned over a wide range by changes in the chemical nature of A, B and X, as well as by variations of the crystal structure. On the basis of our results, we provide some practical rules to tune the valence band maximum, respectively the conduction band minimum, and thus the band gap in this class of materials.