Nothing can burn on earth without the presence of oxygen.
As what we call “fire” or “burning” is a chemical reaction in which atoms of oxygen combine with atoms of carbon from the fuel, the substance being burned, to produce carbon dioxide, light, and heat.
Since fire needs oxygen, and there is almost no oxygen in space, then how can the sun burn constantly? Well, the sun isn’t “burning” in the same sense that a fire burns on earth. The sun produces energy the same way that a hydrogen bomb produces energy.
In this process, hydrogen is changed into helium, but some hydrogen is instead converted into energy. So the sun continues to “burn” and produce light and heat without oxygen.