The crystal structures of Zn and Cd deviate from an ideal hexagonal close packing by a significantly increased c / a ratio. In order to investigate the electronic reason for this deviation, especially with regard to the nearly ideal hcp element Mg, Hartree-Fock and density functional theory calculations were performed, employing various functionals within the local density or the generalized gradient approximations as well as hybrid functionals. The cohesive energy, lattice constants optimized with respect to the energy and elastic constants were computed. The role of electronic correlation in consideration of the filled d-shell is emphasized, postulating different intra-and inter-layer interactions, both in Zn and Cd. On the potential energy surface in the space of varying lattice constants, a path is explored that corresponds to a uniaxial compression along the c axis. In contrast to Mg, the potential energy surface of Zn and Cd is very flat along this path, and an electronic topological transition occurs, leading to a Mg-like band structure.