An interval is the relationship between any two tones. Sometimes it is defined as the distance between tones, & that is one dimension to what they are. Yet, more than that, intervals are sounding relationships, or interactions, between any two tones.
The open strings in standard tuning have particular set of intervals between the strings.

From the 6 & the 5 strings, the interval shapes are the same. The black dot is any given root.




Whatever line or space the note is on, is the line or space you start counting from (it is the 1). In the example, the first line of the staff, E, is 1, since the note-head is on that line.

When E is 1, the F space is some type of 2, the G line is some type of 3, the A space is some type of 4, the B line is some type of 5, the C space is some type of 6, the D line is some type of 7, the E space is some type of 8. The type will depend on whether the tones are naturals, sharps, or flats [or double sharps or flats].

The counting is pretty easy [just keep in mind to start counting from one, from the note you are determining intervals from], yet the some type aspect is typically what provides the challenge.
Visually, it helps to know the following. In music notation rules, visual spacing allows use to quickly identify interval types. Pairing this information with knowledge of the fretboard and guitar intervals, we can interpret more efficiently, even without having to keep note-tone names in mind, as in the case of transposing.
When we play a scale, one tone to the next to the next, this is playing in steps (2nds). Steps are 2nds. E to F is a 2nd. F to G is a 2nd. Yet, E to F is one fret, while F to G is two frets. Therefore, there must be two types of 2nds [a one fret 2nd, & two fret 2nd]. This is true. And, this idea applies to 2nds, 3rds, 6ths, & 7ths.
A one fret 2nd is called a minor 2nd [m2] = 1 half-step = 1 fret
A two fret 2nd is called a Major 2nd [M2] = 2 half-steps = 2 frets
