Core accretion
The leading idea for how giant planets form: a solid core of rock and ice grows first, then pulls in a huge envelope of gas.
Core accretion is the main explanation for how giant planets such as Jupiter and Saturn formed. In the disc of gas and dust around a young star, solids clump into a core of rock and ice. Once the core is massive enough, roughly ten Earth masses in classic models, its gravity pulls in the surrounding hydrogen and helium faster and faster: runaway gas accretion.
It is a race. Most young stars lose their gas discs within a few million years, so the core must grow quickly. Sweeping up small pebbles slowed by the gas (pebble accretion) can speed this up.
Everyday picture: a snowball rolling downhill grows slowly at first, then gathers snow faster the bigger it gets.
A common misconception is that a giant's core is a neat solid ball. NASA's Juno found that Jupiter's heavy elements seem to be spread out: a dilute core. The rival idea, disc instability, makes a giant directly from a collapsing clump of gas.