Why Does a Liquid Take the Shape of Its Container but Not Expand to Fill Its Volume?

The particles in a liquid are not stuck in fixed positions, which is why liquids flow to take the shape of a container into which they are placed. However, the particles in a liquid are also close together, so they have a set volume and cannot expand beyond that.

The intermolecular attractive forces in liquids are strong enough to keep the volume constant. In gases, unlike liquids, the particles are not close together and do not have fixed positions. Since gases are mostly empty space, they can be compressed and can expand to fill the volume of a container. Gases can also flow to take the shape of a container.