From MusiCAD

A semitone or half step or half tone is the smallest musical relevant step (interval) in pitch that is used on most instruments and in (Western) tonal music.

An octave in this context is made up of twelve equal semitone steps.

# name ratio
0 prime 1:1
1 minor second
2 whole tone
3 minor third 6:5
4 major third 5:4
5 perfect fourth
6 diminished fifth
7 perfect fifth 3:2
8 minor sixth
9 major sixth 5:3
10 minor seventh
11 major seventh
12 octave 2:1

In written music, it is not immediately obvious what the interval is; the distance between two note-positions can vary.

Two notes both written on the same g-line can have distances ranging from zero to two. When allowing double sharps and flats the range extends to four semitones...

gb - g# 2
g - g# 1
gb - g 1
g - g 0


Note-distance in semitones shown in red.

Scale position in blue.

See also