What is the composition of a quasar compared to a star or nebula?
A quasar is an active galactic nucleus.
A nebula is a cloud of gas and dust. It is mainly Hydrogen, with some helium and small quantities of heaver elements and compounds. Nebulae are where stars are born.
A star is a ball of gas which is mainly Hydrogen. The temperatures and pressures in a star's core are high enough to sustain fusion reactions. Stars emit light and heat.
A galaxy is a collection of stars. Most galaxies have a supermassive black hole in their centres. Young galaxies and galaxies which have collided with another galaxy have large amounts of dust and gas in the area surrounding the supermassive black hole.
Dust and gas close to the supermassive black hole stars to fall into the black hole. It forms a disk called an accretion disk. As more and more material falls into the accretion disk it gets superheated by friction and gravity. All of the energy then gets emitted as powerful beams of radiation. This is a quasar.
Young galaxies are most likely to be quasars. When the area around the supermassive black hole gets depleted of material, the galactic nucleus ceases to be a quasar.