Here's why:
* Excitation and Emission: When you heat sodium salts in a flame, the energy from the heat excites the sodium atoms. This means the electrons in the sodium atoms jump to higher energy levels.
* Energy Release: When these excited electrons return to their ground state (lower energy level), they release energy in the form of light.
* Wavelength and Color: The energy released by sodium atoms corresponds to a specific wavelength of light, which falls in the yellow part of the visible spectrum.
Therefore, the yellow color is characteristic of sodium ions (Na⁺) and not specific to the anion present in the compound.
This is a very useful phenomenon in chemistry. Flame tests are used to identify the presence of certain elements in a sample based on the color they produce when heated in a flame.