A body floats or sinks due to its
Density
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, it is due to the difference in density of body and fluid, it floats or sinks.