There are several different techniques that allow a DJ to change from one record to another without introducing a silence (that might ruin the atmosphere). Often a good DJ will use more than one technique, but for simplicity I will describe them separately.
Beat mixing is where a DJ speeds up or slows down a record, so the beats of one record are in time with another record. Often this is aided by the intro, and ending of record being totally based on drumbeats. Almost all DJs will use this technique for every "mix" they do. House music is probably the best type of music to practice this technique with, as most house tunes will have a long beat-based introduction.
Scratch mixing is where the DJ "pulls" and "pushes" the record to create a unique "scratching" sound. This is often employed by Rap, Hip Hop and RnB DJs.
Pitch mixing (a.k.a. Key or tone mixing):- technically for a DJ to do this they would need to alter the pitch of the tunes they play, but often a DJ will have enough tunes to ensure the next song he plays will mix with the current one without clashing. A simple way to avoid this clashing is to simply wait until the end playing tune, where most dance music has a section of just beats (with no tone or background instruments), or ensure the next tune starts with just beats. The realtime-loop on more advanced CD players can help with this, as you can just make the first few beats loop. This is especially useful if you are playing more pop/commercial dance rather than 12" dance mixes.
One thing worth noting is that older music (such as soul, rare groove etc) or music recorded live will be very difficult to beat match well. This is purely because the drum beats are often produced by a human and not produced by a drum machine or synchronised using a computer sequencer, and hence aren't perfectly in rhythm.