Density is an important characteristic of substances, crucial in determining whether an object sinks or floats in a fluid. Its SI unit is kg/m3, and its cgs unit is g/cm3. The density of an object helps in identifying its composition, and also reveals information about the phase of the matter and its substructure. The densities of liquids and solids are roughly comparable, consistent with the fact that their atoms are in close contact. However, gases have much lower densities than liquids and solids because their atoms are separated by large amounts of empty space.
The density of a substance is not necessarily constant throughout its volume. If the density is constant throughout a substance, it is said to be a homogeneous substance. An example of a homogeneous substance is a solid iron bar, whose density is constant throughout, and so the density of any sample of the iron bar is the same as its average density. If the density of a substance is not constant, it is said to be a heterogeneous substance. A chunk of Swiss cheese is an example of a heterogeneous material, containing both solid cheese and gas-filled voids. The density at a specific location within a heterogeneous material is called the local density and is given as a function of location. Since gases are free to expand and contract, their densities vary considerably with temperature, whereas the densities of liquids vary little with temperature. Therefore, the densities of liquids are often treated as constant, with the density equal to the average density.
Density is a dimensional property; therefore, when comparing the densities of two substances, the units must be taken into consideration. For this reason, a more convenient, dimensionless quantity called the specific gravity is often used to compare densities. Specific gravity is defined as the ratio of the density of a material to the density of water at 4.0 °C and one atmosphere of pressure, which is 1000 kg/m3. The comparison uses water because the density of water is 1 g/cm3, which was originally used to define the kilogram. Specific gravity, being dimensionless, provides a ready comparison among materials without having to worry about the unit of density.
This text is adapted from Openstax, University Physics Volume 1, Section 14.1: Fluids, Density, and Pressure.