Not many guitar players know this, but it's actually impossible to have your guitar perfectly in tune to pure notes everywhere on the neck. You may have noticed yourself that sometimes if you perfectly tune a pure E major chord for example, then the next chord you play sounds offensively out of tune. This is due to a phenomenon called "Inharmonicity", present in all plucked or struck stringed instruments.
A plucked open string on a guitar vibrates with a speed that has a fundamental frequency. It also produces a series of harmonic overtones. If we divide a string into two halves, then at the twelfth fret we get a harmonic which produces a pitch one octave higher than the fundamental. This occurs because the string is vibrating twice as fast. For example, the first A above middle C on the piano (or 5th fret on the guitar's high E string) has a frequency of 440Hz. If we half then length, the speed doubles. Mathematically the first harmonic at the 12th fret should be vibrating at 880Hz.
But it is not!!!. It vibrates slightly faster and therefore the pitch will be slightly sharper. This occurs because of the physical properties of strings. The less elastic they are, the more inharmonicity present.
In early pure tuning methods such as Pythagorean Tuning, one or several intervals were unpleasantly out of tune creating a problem for any musician/composer that wanted to modulate to different keys. In the 16th century a system called "Equal Temperament" was invented where all 12 keys were made to sound acceptable without having to retune to a new key. This was done by approximating the intervals between notes rather than using the Mathematical values.
Equal Temperament is how the modern day guitar is tuned and within this system all octaves should be pure. Using this knowledge, I like to tune my guitar using an octave method which ensures that the instrument is acceptably in tune all over the neck. Many people use the 5th fret method and tuning against open strings, but more often than not, I personally find this results in poor tuning.
How to tune
fig 1 - octave shapes across the guitar neck. Each group of two notes is the same but one octave apart.
Ensure that your top and bottom strings are perfectly tuned to E, using either a tuning fork or an electric guitar tuner.
From fig 1 above, make the first shape for an octave interval on the low E and D strings (5th and 7th fret respectively). Remember, octaves are exactly in tune in Equal Temperament, so pluck the low E string first on the 5th fret and then pluck the D string second on the 7th fret, tuning the D string until it is exactly one octave above.
Repeat the process for the D to B strings (fig 1, 3rd chord box from left).
Now work backwards from the top E string. Pluck E at the 8th fret first and G at the 5th fret second, tuning the G string so that it is in tune with the E string (fig 1, chord box on far right).
Now repeat tuning the A string at the 8th fret from the tuned G string at the 5th fret (fig 1, 2nd from left chord box).
All your octaves should be perfect at the 5th fret position. Now move all the octave intervals in fig 1 so that the first finger will be on the 9th fret and repeat the process, making any fine tuning adjustments if necessary.
Repeat the fine tuning process at the 3rd fret.
If the Octaves are in tune in these places, then the guitar is perfectly in tune everywhere! Happy playing!