The elements heavier than hydrogen and helium were produced inside stars.
During most of a star's lifetime, hydrogen nuclei fuse together to form helium nuclei.As the star runs out of hydrogen, other elements. Heavier elements than hydrogen and helium are form. Elements heavier than iron are formed in supernovas.