All the bros here talk cock on defence matters, LOL. Want to know how to destroy a carrier (assuming USN), come and talk to PAPsmearer lah. Firstly, forget about surface attack. There is no navy out there that can send a strong enough fleet of surface vessels that will survive a defence by a US Carrier Battle group. They will be sunk way before they can launch or fire anything.
Forget about aerial attack, and that includes missiles too. With satellites, AWACS, etc., the CBG will detect an air attack or missile attack long before it gets to the fleet. The F-18 Super Hornets will down the enemy planes with AAMRAM long before they can launch any air to surface missiles. Even for land launch missiles like SIlkworm or Tomahawk, its extremely difficult to program the carrier profile into the computer. Likely, the enemy has to launch a SIlkworm in the direction of the fleet and hopes that it hits the carrier and not one of the screening vessels. SAme for the air launched missiles. Even if an air launched missile in the Harpoon or Exorcet class hits the carrier, doubtful the size of the warhead will sink the carrier. The carrier will survive multiple hits from this small warheads. Even if the Harpoons or Exorcets are programmed for top down attack, they will impact the carrier deck or bridge, and if they are lucky detonate a fully fueled and armed aircraft on the deck. Even than, the fire control systems on a US carrier are excellent. Might cripple it and make it inoperable, but not likely to sink or destroy it. And larger missiles like Silkworm which has a large enough warhead will likely be shot down by a combination of F-18s, Sea Sparrows and Phalanx. The only posibility with a large missile is to send salvoes of the missiles, and hope to saturate the defence of the fleet. But Even than, you will destroy some ships, but whether the carrier is one of them or not, is more luck than planning.
Forget about submarines sinking the carrier, as every CBG (CArrier Battle Group) is escorted by Los Angeles class attack sub or newer models. Their job is to hunt the enemy sub and sink it. As well, the fleet is equipped with ASW helos, not only from the carrier, but also from other ships like the Aegis class destroyers. American anti submarine warfare is head and shoulders above the rest of the world. Very hard to send a sub against them. The only hope you have is to keep a sub in the littoral waters (near the coast), in an area with many geographic features on the seabed, and wait for the CBG to come by. Than pop up and fire a salvo of torpedoes at the carrier. Littoral areas make sub detecttion harder, But this is a suicide mission anyway, and I don't know what sub commander would do that. Also, you have to know the timing and route of the CBG.
To my knowledge, there is only 2 ways to destroy a carrier. The Russians figured it out long ago. You have to launch a nuclear strike against the entire CBG. Either you use a missile launched from land or air to target the entire fleet, with a high enough yield that it will destroy not only the carrier, but also the surrounding fleet.
Or, you wait for the carrier to go into a port. All carriers including nuclear, will port sometime. using Changi Naval base as an example, when a USN carrier docks there, an enemy will have the opportunity to send several high speed small boats packed with explosives and get next to the carrier and detonate the boat at the water line. This strategy was used successfully against the destroyer USS Cole in Somalia. The only mistake was they used one small speedboat instead of several, otherwise, the Cole would have been sunk. The carrier will definitely be defended while in port, but you take away its advantage of its air wing and its aircraft, its ability to maneuvre, and its screening vessels. U also have a mostly empty vessel with most of the crew on liberty.