Naval combat occurs when units based in the sea enter combat, either with other naval units, or with units or cities on land.
Like land units, there are military and non-military naval units, as well as ranged, and melee naval units. Each of those enter respectively in either ranged, or melee combat with other units on the sea. Note also that early game naval vessels (the Trireme and the Galleass) may not enter ocean tiles unless they are owned by Polynesia. This means that Triremes cannot attack targets in ocean tiles, since they need to actually move into the target tile.
Ranged naval combat units may attack other naval units and any units on land within range that they can see (with the exception of submarines, which can only attack other naval units). Melee naval units may attack other units in the sea, or coastal cities. They are also the only ones that may capture cities.
There are certain late-game naval units that merit special attention: the Carrier, the Missile Cruiser, and the Nuclear Submarine. Those vessels are able to load other units in them: the Carrier loads 2-5 Aircraft (depending on Promotions), while the Missile Cruiser and the Nuclear Submarine can carry respectively three and two ballistic/nuclear missiles.
Any embarked land units are NOT considered naval units. As such, they are very vulnerable to attacks, although they can absorb a hit or two. They can't attack other naval units, although they return fire in melee combat.
Naval combat is generally like Land combat, with some important exceptions. First, there are far fewer combat bonuses to be had, since there is no defensible terrain in the sea. Melee attacks, however, are still subject to Formation bonuses. And also, Great Admirals can enhance your fleet's power. Otherwise, Ranged attacks damage targets without them being able to retaliate, while Melee attacks damage both vessels. When a vessel is destroyed, it sinks, and the victor enters its tile.
The most interesting thing about naval combat comes in the Modern Era, with the invention of Submarines. These unique units move under water and are consequently able to remain invisible to all other units (except special detector units), until they end their turn in a tile next to an enemy, or until they attack. They are also the only units in the game able to enter Ice tiles, moving below the surface ice, which also conveys strategic advantage.
Submarines are Ranged units with 2 range, and what's even more important, they receive a 100% Attack bonus, making them almost one-shot killers and perfect for hit-and-run attacks.
As if that weren't enough, the Nuclear Submarine is able to carry Ballistic missiles, meaning that it could deliver a Nuke right at the enemy's doorstep!
Submarines are considerably weaker when attacked, though. The catch is that you need to see them to attack! There are only a handful of units that may see Submarines normally; they will also make the Submarine visible (attackable) to all other units:
Of those, the first two also have a combat bonus when fighting Submarines. Use them to defend against Submarines by constantly patrolling the seas.
These are special units designed to bring aerial units into the sea. Each Carrier may carry up to two (more with promotions) airplanes, providing a base of operations for them, and use their considerable power and operational range to attack navies or land units and cities.
Carriers become very important in modern warfare, especially when a player needs to attack a civilization on another continent. The Air power brought by them can serve both to devastate the enemy land army, and to protect from enemy aviation.
Carriers, however, cannot attack themselves. They have Combat strength, but only for defensive purposes, and can't match later, more powerful naval or aerial units (although certain Promotions can make them tougher). So always make sure you defend your Carriers, and attack enemy Carriers as a priority!
Ranged naval units may attack land units on the coast, if the targets are in range (also, they need to 'see' the targets, according to the rules of Ranged combat). They are quite effective when bombarding land units, especially if they've acquired the relevant promotion.
Land units are also quite the target while Embarked. In this case they may be attacked by both Ranged and Melee naval units to devastating effect. Always when you need to transport your Land army across a body of water, make sure there are no enemy vessels nearby, or that you escort them with your own navy.
On the other hand, land Ranged units may also attack naval units in the sea, if in range. They, also, are quite effective. Beware of Bombers with a special promotion - they can devastate a navy!
Melee naval units may attack coastal cities, and many of them get a bonus when doing so (although, as per the rules of City Combat, both the city and the vessel suffer damage). Privateers, and any other unit with the 'Coastal raider' Promotion also steal Gold from the owner of the city with each attack! Note that Naval melee vessels may capture cities!
Unlike Land units, naval vessels may not Heal unless they're in Friendly territory. The special promotion, 'Supply', alters that, permitting Healing everywhere. Also, a Great Admiral may Heal instantly vessels when using its special ability.