stars begin as a giant cloud of gas which is also a protostar. gravity will pull the gas in on intelf which increases heat and pressure to such great quantities that nuclear fusion can begin. hydrogen is the first and simplest element so there is a lot of it present. under the great temperatures and pressures, the hydrgen nuclei of 2 different atoms will react and fuse together to form helium nuceli. this reaction will continue and later on heavier elemnts may be present like iron, oxygen and carbon. when the star runs out of hydrogen it may swell and become a red giant. if it is a small star, once all the elemnts are used up it will shrink into a dwarf star and eventually disappear. if its a large star it will swell and can explode in a supernova.