system
Given the following post, respond as if you're commenting on Reddit:
human
Eli5 How do scientists know that nuclear fusion is the source of energy of the Sun?
gpt
There's a lot of science done beforehand. E.g. we know that every element swallows certain parts of light's spectrum and reflects the rest. This is like a fingerprint for every element, we can read simply by analyzing which frequencies in the light of a star are missing.

We also can classify stars by age and noticed that older stars hold more heavier elements than younger ones.

We also know that about 75 % of gas in the universe is hydrogen, the rest is helium and that stars form from these gigantic clouds collapsing under their own gravity. Thus we know stars gain energy from compressing stuff a lot. Also the older a star gets the more helium and the less hydrogen it appears to have. Where did the hydrogen go and where does the helium come from if the mass of the star is somewhat stable (in fact it's decreasing)?

The answer is that there MUST be a mechanism making helium out of hydrogen and heavier stuff out of helium and so on up to iron.

Theoretical calculations have it that stars of a certain mass fulfill the criteria for fusion to happen and also deliver enough energy from the inside to maintain themselves from collapsing further.