Sunlight is made up of different colors that are rainbow colors: violet, indigo, blue, green, yellow, orange, red. When sunlight falls on water some part of it is reflected back and other enters the ocean. The light gets scattered after entering the ocean by ripples and other particles in it.
Oxygen present in the deep water bodies scatter blue light more as compared to less deep water bodies. This is one factor why ocean appears blue. Other reason is that when sunlight falls on water the part of light is reflected back which reflects color of the sky.
Actually, when light enters the water body, upper part of the water absorbs red and yellow light only green and blue light is not absorbed which makes ocean appear blue or we can say that wavelength of light depends upon the composition of material. Blue wavelength penetrates deep into the water while other wavelengths get absorbed on the upper level.
If we go deep into the water everything will appear blue as yellow and red is absorbed on the upper layer of ocean and blue gets reflected from the objects in the sea. Some oceans appear green because of the presence of much plant life under water blue light is mixed with yellow pigment of plants gives green color to the ocean. Red sea appears red because of red algae and black because of excessive amount of hydrogen sulphide.