Considering mass percentages, stars in the vicinity of the sun contain only 2% other elements by mass. Other than the main components, hydrogen and helium, stars have some heavier elements such as carbon, nitrogen, oxygen and iron. These elements are found near or in the star's core and are ejected into space when the star dies.