Stars probably begin as clouds of hydrogen and dust. This material slowly pulls itself together into clumps. As the material gets packed in tighter, the clumps get hotter. Pressure builds up. Eventually the star begins changing hydrogen into helium—and so begins to shine brightly.
After shining for billions of years, a star uses up all its hydrogen. Small and medium stars slowly cool down and stop shining. This will happen to the Sun billions of years in the future.
Large stars end with a violent explosion called a supernova. After that the material gets crushed much smaller. It no longer shines. Huge stars may end up as objects called black holes. The crushed material is so heavy for its size that it develops a powerful inward pull. This pull, called gravity, is so strong that it sucks in anything that gets near the black hole.