By means of detailed chemo-photometric models for elliptical , spiral and irregular galaxies , we evaluate the cosmic history of the production of chemical elements as well as the metal mass density of the present-day universe . In particular , we study the production rates of some of the most common chemical species ( O , Mg , N , Si , Fe , Zn ) , detected both in local stars , galactic and extragalactic HII regions and high redshift objects . Such a study allows us to compute in detail the fraction of each element locked up in stars , interstellar gas and intergalactic medium . We then calculate the mean metal abundances for galaxies of different morphological types , along with the average metallicity of galactic matter in the universe ( stars , gas and intergalactic medium ) . For the average metallicity of galaxies in the local universe , we find < Z > _ { gal } = 0.0175 , i.e . close to the solar value . We find the main metal production in spheroids ( ellipticals and bulges ) to occur at very early times , implying an early peak in the metal production and a subsequent decrease . On the other hand , the metal production in spirals and irregulars is always increasing with time . We find that the average [ O / Fe ] _ { *,E } ratio in stars in spheroids should be +0.4 dex , whereas the average [ O / Fe ] _ { gas,E } ratio in the gas should be -0.33 dex , due to the large amount of Fe produced in these systems by SNae Ia after star formation has stopped . The same quantities for spirals are \sim + 0.1 dex for the stellar component and almost solar ( \sim + 0.01 dex ) for the gas component . We suggest that a Salpeter-like IMF is the best candidate for the universal IMF since it allows us to reproduce the majority of observational constraints . We perform a self-consistent census of the baryons and metals in the local universe finding that , while the vast majority of the baryons lies outside galaxies in the inter-galactic medium ( IGM ) , 52 \% of the metals ( with the exception of the Fe-peak elements ) is locked up in stars and in the interstellar medium . We estimate indirectly the amount of baryons which resides in the IGM and we derive its mean Fe abundance , finding a value of X _ { Fe,IGM } = 0.05 X _ { Fe, \odot } . We believe that this estimate is uncertain by a factor of \sim 2 , owing to the normalization of the local luminosity function . This means that the Fe abundance of 0.3 solar inferred from X-ray observations of the hot intra-cluster medium ( ICM ) is higher than the average Fe abundance of the inter-galactic gas in the field .