The composition of planets is determined by and tightly linked to the composition of the protoplanetary disk in which they form. In the first part of my talk, I will discuss giant planet formation through core accretion. I will show how the minimum core mass required to form a giant planet during the lifetime of the protoplanetary disk depends on the location in the disk, the equation of state of the nebular gas and dust opacity. This minimum applies when planetesimal accretion does not substantially heat the core's atmosphere. The minimum core mass decreases with semimajor axis, and may be significantly lower than the typically quoted value of 10 Earth masses, thus challenging previous studies that core accretion cannot operate in the outer disk. In the second part, I will explore how the composition and evolution of protoplanetary disks may affect the formation and chemical composition of giant planets. Volatile snowlines are highly important in the planet formation process. I will thus show how the snowline locations of the main carbon, oxygen and nitrogen carriers, as well as the C/N/O ratios, are affected by disk dynamics and ice morphology. Compared to a static disk, disk dynamics and ice morphology combined may change the CO and N2 snowline locations by a factor of 7. Moreover, the gas-phase N/O ratio is highly enhanced throughout most of the disk, meaning that wide-separation giants should have an excess of nitrogen in their atmospheres which may be used to trace their origins. The large range of possible CO and N2 snowline locations, and hence of regions with highly enhanced N/O ratios, implies that snowline observations at various stages of planet formation are crucial in order to use C/N/O ratios as beacons for planet formation zones.