I have seen one or two fretless guitars in my time, but the vast majority of guitars are fretted instruments. The frets are placed precisely at specific points along the fretboard and the distance between them decreases steadily from the first fret (near the nut), to the last fret (where the neck meets the body of the guitar).
Violins, Violas, and Cellos are fretless instruments and the musicians who play them must be more precise with their finger placement. That's not to say that guitarists can be careless or sloppy, because - if a guitarist accidentally bends a string while playing, the note or chord will be out of tune to some degree. I think they now call that Punk.
Each of your guitar strings is a particular thickness and length. When you strike an open string it vibrates at a particular frequency (rate of vibration) which is determined by the tension and the length of the string. The length is actually dictated by the distance from the nut to the bridge. If you place a finger in one of the frets - in effect, making the string shorter - and strike it, a higher frequency (note) is produced. The frequency of the fingered note will be inversely proportional to the difference between the "open" length of the string, and the distance from your finger to the bridge (or, to state it more precisely: "the distance from THE FRET ABOVE YOUR FINGER to the bridge").
Theoretically, if you place your finger exactly half way between the nut and the bridge, (the 12th fret) the frequency of the note should be twice that of the open string. Actually, due to the differences in gauge of each string, and, the wearing of the strings and frets as they age, or, misalignment of the neck - the half way point does not necessarily produce a note having exactly twice the frequency of the open string. Therefore, the intonation of some notes in and near the 12th fret will be "out of tune". To remedy that, you must adjust the bridge in order to correct the location of the "halfway" point by compensating for the physical inconsistencies of your strings and frets.
Before you make any adjustments to the intonation, be sure that your guitar's neck is not bent, warped, bowed, or tilted. If any of those conditions exist you must first correct them (as described earlier). Failing to do so can cause errors and much frustration while you are adjusting your guitar's intonation.
If the neck is aligned correctly, you must next determine how to adjust the intonation on your particular make and model of guitar. Most electric guitars have spring-loaded screws located on the bridge somewhere, which move the bridge forward (making the string a little shorter) and backward (making the string a little longer) in relation to the nut of the guitar. Only an EXPERIENCED guitar technician should do ACOUSTIC guitar intonation adjustments!
Ideally, as with adjusting the height of the bridge, you want each string to have it's own individual bridge in order to adjust the intonation more accurately. Some guitar models don't provide individual bridges, so, you have to compromise by making adjustments that are best overall, but not extremely precise for all strings. Figure GM-6 shows a bridge that has an individual intonation adjustment screw for each string. Turning the screw clockwise lengthens the string by moving the bridge away from the nut at the far end of the neck. Turning it counterclockwise shortens it by moving the bridge forward toward the nut (by force of a spring).
Once you have determined the type of bridge you have and the mechanism provided for adjusting the intonation, you are ready to adjust the intonation. I strongly suggest that you use an electronic tuner to check the tuning as you make the following adjustments.
Start with your top string by playing an open note and tune it to the electronic tuner. Be patient and precise. Next, place a finger in the 12th fret of the string and strike the note. Check to see if it is tuned to the same note ('E', it should be close to being the same note as the open string but an octave higher). If the tuner indicates that the note in the 12th fret is lower than the open string, you must move the bridge forward toward the nut slightly. If the tuner indicates it is higher than the open string, you must move the bridge away from the nut. Always make small adjustments. It's IMPORTANT that you tune the open string after each adjustment because moving the bridge will also change the tuning of the open string!
So, re-tune the open string then play the 12th fret again to see if the two notes are closer (though an octave apart). Keep adjusting the bridge until the tuner indicates they are both tuned to 'E'. But don't stop there! You should next play a "harmonic" tone by placing your finger very lightly on the string in the 5th fret, and then strike the string and lift your finger from it at the same time. Check the tuner to see if the harmonic tone is tuned. Then, play the harmonic tone at the 12th fret and compare the tuning of this note with the tuner. Repeat the process until both harmonic tones, AND the open string AND the fingered 12th fret give you an identical reading on the tuner.
When all four notes (i.e. the open string, 12th fret, 5th fret harmonic, 12th fret harmonic) give the same reading, stop making adjustments and move to the next string and repeat the entire process for each string. NOTE: AFTER ADJUSTING THE INTONATION FOR EACH STRING YOU SHOULD RE-ADJUST THE BRIDGE HEIGHT BECAUSE IT WILL HAVE CHANGED DUE TO THE INTONATION ADJUSTMENTS YOU MADE.
You can read more about Harmonic Tones in the lessons about GUITAR TUNING