The solar system formed from a large rotating cloud of dust and gas called the solar nebula. As the nebula collapsed, a section broke off to form the solar system with the sun at its center. Gravity drew particles together, forming the sun and other planetary bodies like planets, moons, and asteroids. The inner planets are rocky and close to the sun, while the outer planets, or gas giants, are large and more distant.