Absorption energies of hydrogen in Mg and Ti as a function of the hydrogen concentration were calculated using density functional theory. We investigated hydrogen absorbed in metal hosts with different structures ͑fcc, hcp, and bct for Mg; hcp and fcc for Ti͒. The most stable configurations were determined for different hydrogen concentrations. Rutile and fluorite structures are found to be the most stable for Mg and Ti hydrides, respectively. Preference of hydrogen filling up the interstices of the metal hosts, and crystal lattice transformations and distortions were also investigated. Hydrogen atoms prefer to pair up and form clusters in Mg; but hydrogen atoms like to occupy sites which are apart as far as possible in Ti. The differences in the hydrogenation behavior of Mg and Ti were compared and analyzed using the electron density. The hydrogenation behaviors can be related to bonding characteristic of Mg and Ti hydrides. Mg hydride is more ionic than Ti hydride.