A dive is a move that can be performed in midair to cause Mario to lunge forward. It can be initiated by pressing X or Y while Mario is in the ground pound animation in midair. Most often, dives are performed by pressing X or Y immediately after pressing ZL or ZR to ground pound.
Performing a dive causes Mario's height to increase by 182 units, which makes them useful for diving up onto a ledge at the end of a vertical trickjump. Dives also propel Mario forward a fair amount, and this happens to be the perfect distance to hit Cappy after throwing him to perform a cap bounce.
Because a dive must be performed following a ground pound, it resets Mario's momentum to a fixed value in a similar manner to the long jump. This actually makes diving often somewhat suboptimal for speedrun movement in places where Mario has enough momentum, unless there is no other movement alternative.
After diving, there is no way to cancel the dive animation until Mario touches the ground. If the ZL or ZR button is held while Mario touches the ground, Mario will enter a roll upon landing (unless he has fallen a very long distance and does not have enough forward momentum, which will cause a fall stun to occur instead).
If Mario impacts a wall during a dive, it will cause him to bonk.