Hammer-ons and pull-offs are two closely related techniques. They are used to play legato, that is, in a smooth manner, and are also used to help the guitarist to play faster. They are most commonly used in electric guitar work, but can be used in acoustic tunes as embellishments.
Quickly pressing your finger down and raising the note without hitting the string again is called “hammering on”. Without electric amplification, the hammer-on tends to be quieter than regularly struck notes, especially if you haven’t practiced it! Because the strings are closer to the fretboard, hammer-ons are easier to execute on an electric guitar.
The hammer-on can just as easily be played with fretted notes: just play the note normally and hammer onto another (higher-numbered) fret on the same string. If you practice hammer-ons, eventually you will be able to move each finger smoothly and independently.
The pull-off is the opposite of the hammer-on. Again, using the E string, hold it at the third fret. Strike the string and while the note is still ringing, release the fretting finger. If done properly, the G should be followed by an open E. If the note doesn’t ring out properly, try hitting the G harder and releasing faster.
Like the hammer-on, the second note tends to be less loud than the first. To help alleviate this, a slight sideways motion of the fretting finger while pulling off will add extra vibration to the string, and give you some extra volume. Often it is hard for a beginner to accomplish, and the sideways movement helps greatly.
A trill is two alternating notes, such as an A and A#. Only the first note is struck; the rest are rapidly hammered-on and pulled off.