Variety of colours is seen from fire works. How do these colours come from fire works?

The electrons present in atoms of elements absorb energy and move to excited states and when they return back to ground state with emission of energy in visible spectrum. So the colours observed during fire works is the emitted energy by various elements in different fire works.