A firework is an explosive device. It is like a little bomb.
The firework contains a mixture of chemicals. When this mixture is heated, a very rapid chemical reaction takes place. This produces a huge amount of hot gas.
All of this takes place inside a cardboard tube. In a rocket the lower end of the tube is often simply paper, while the upper end is cardboard. So when the hot gases try to get away, they shoot out of the bottom, and this is what causes fireworks like rockets to shoot into the sky.
In a Roman Candle it is the other way around.
You can use a variety of chemicals to make colours to make the firework more exciting. You can also control the rate of reaction so that the gases appear to pour out of the top of a firework to make a Roman Candle.
A sparkler is a firework that is made so that it produces showers of tiny burning particles of metal. See the entry 'sparkler' for more.