The eight planets of our Solar System vary widely, not only in terms of size, but also in terms of mass and density (i.e. its mass per unit of volume). For instance, the 4 inner planets – those that are closest to the Sun – are all terrestrial planets, meaning they are composed primarily of silicate rocks or metals and have a solid surface. On these planets, density varies the farther one ventures from the surface towards the core, but not considerably.
By contrast, the 4 outer planets are designated as gas giants (and/or ice giants) which are composed primarily of of hydrogen, helium, and water existing in various physical states. While these planets are greater in size and mass, their overall density is much lower. In addition, their density varies considerably between the outer and inner layers, ranging from a liquid state to materials so dense that they become rock-solid.