There are two ways for an object to float. Option 1: the object is less dense than water so it won't sink no matter what. Option 2: due to not being able to break the surface tension of water, the object is held up.
In the case of option 2, the water is pushed down due to having to "carry" the object. In the case of option 1, you'll be able witness the water slightly go up along the edges of the object.
There's the famous saying of opposites attract, however in this case it's quite the opposite. Objects that can float due to low density attract each other and objects that float due to surface tension attract each other. They also repel the other type of object.
Option 2 is harder to imagine so I'll just give an example. The material of a paper clip is something that is obviously denser than water. If you drop a paper clip into water, it will almost certainly sink. There is however an exception. If you're very careful in placing the paper clip, it will float.