Here we'll look at how the range of the guitar fretboard compares to the piano keyboard, and then a little bit about half-steps & the ergonomics of frets and keys.
Below is a representation of an 88-note piano keyboard.
C1 on the left is the lowest C.
C8 on the right is the highest C.
The orange key labeled E2 is the same note & pitch as the lowest open guitar string — the low E string.
The other orange key labeled E5 is the same note & pitch as the 12th fret on the highest guitar string — the high E string.
(the 13th fret and upwards are a duplicate of the fretboard starting on fret 1.)
Here's how the same range of notes look on the grand staff (the numbers are strings 1-6):
Compare these notes on your guitar and a piano to hear this for yourself.
To the left is a single octave worth of keys on the piano keyboard, from C4 to C5.
We can think of this as an ergonomic layout of the piano keys, which means this layout is a relatively comfortable arrangement of the piano keys, which hopefully causes as little strain as possible on the human hands when playing.
As a comparison, here is an example of an ergonomic computer keyboard.
Both of these tools have very different uses, but are both setup to limit the negative physical impact on the human hands that may be using either one of these tools for hours upon hours each day.
In contrast to the ergonomic computer keyboard above, here are two commonly used regular computer keyboards, one for PC users and the other for Mac users.
Here are the piano keys above laid out in a non-ergonomic (and un-realisitic) arrangement — notice the black keys are the same size as the white keys, which creates an even spacing between all the keys.
In this diagram, all the keys are one half-step apart from each other.
Notice the labels pointing out all the 1/2 steps between keys (if you're not familiar with what a musical half-step is — think the short & scary lick from the movie Jaws that tells us the shark is close by.)
So then, the black keys on the modern piano keyboard are smaller and shorter for easier playability for our human hands = ergonomic piano keyboard!
Now back to the original piano layout. Again, we have labels pointing out all the 1/2 steps between keys.
So the space between every piano key, whether black or white, is a half step (again, think the short scary lick from the movie Jaws :)
Now let's compare the non-ergonomic (and again, un-realisitic) piano keyboard to the guitar fretboard: the half-steps of the non-ergonomic keyboard line up with our guitar frets.
So, just as the space between each key on this piano is 1/2 step, the space between each fret is also 1/2 step.
(the actual notes here do not line up — as this is only showing how individual piano keys compare to individual frets in terms of musical spacing.)