According to the U.S. Department of Energy Office of Science, objects float because they're less dense than the material in which they're resting. An object placed in water displaces water equal to its volume. If it weighs less than the volume of water it displaces, it floats. If it weighs more, it sinks.
Water has a density of around 62 pounds per cubic foot. If a boat displaces 100 cubic feet of water, it floats as long as it weighs less than 6,200 pounds. The key to making a boat float is ensuring the vessel displaces enough water to more than compensate for its weight. This is why naval ships can be built of heavy, dense materials like steel. Internal air pockets enable the vessel to displace enough water to float.
The same principle works for objects that float in air. In this case, an object must be less dense than the surrounding atmosphere, which is why lighter-than-air objects generally require special gases. Helium is less dense than oxygen, so a party balloon weighs less than the air it displaces and floats. In the case of a hot air balloon, the pilot heats the air inside the balloon's envelope, making it less dense than the surrounding atmosphere and providing lift.