A body floats or sinks in a liquid depends on the difference in their:
Densities
Whenever any body is immersed in a liquid it experiences an upward force. The magnitude of this upward force depends upon the density of the liquid. So the difference in density of body and fluid determines whether a body floats or sinks.