The purpose of the flags is to notify to any other boats to steer clear for the safety of the diver and to avert the possibility of a collision with the dive boat which may be unable to maneuver out of the way.
The use of the red and white flag, which was created in 1956 by Navy veteran Denzel James Dockery and popularised by Ted Nixon of US Divers, is required by law or regulation in many US states, Canada, and some other countries (e.g. Italy). Usually the regulations require divers to display the flag while diving and to stay within a specified distance of it when they are near the surface. There may also be a larger zone around the flag where no boats are allowed to pass. Some states also prohibit the display of this flag when there is no diver in water. It can be placed on a boat or on a surface marker buoy.