This is actually an answer to a question that this question is marked as an exact duplicate of (putting it here to contribute a few more nuances to the body of answers):
I’ve been working on a piece in GarageBand on my iPad that ends with a B7 chord; the little knowledge I have of music theory is only what I have gleaned from practical experience as a three-year member of my high school’s choir, so I would like some clarification on the terms used to define the notes in a chord because I am not very sure that my understanding is correct.
I know the notes in the B7 chord are B, E flat, G flat, and A; I’ve mainly seen the chord as the notes ascending in that order. If I have the notes ascending in the order of Eb, Gb, A, and B, is Eb now the root of the chord, or is the root of the chord always the note that the chord is named after, and therefore the root of the chord is still B?
The usual "spelling" of B7 is B, D#, F#, A. Note that this spelling omits every second letter, so that the chord is a series of stacked thirds; this is typical in Western harmony. A dominant seventh, then consists of the root, a major third above the root, a perfect fifth above the root, and a minor seventh above the root. This chord can of course be inverted; in any case, the root of a chord with those notes is always B, no matter what order they're in.
In this particular case, there is nothing else those notes are likely to be. However, if you examine a Bdim7, on the other hand, you will see that it is spelled B, D, F, Ab. The interval between each of those is a minor third (three half-steps). That means it would consist of the same pitch classes as a Ddim7, a E#dim7, or a G#dim7. (Why didn't I call the last two an Fdim7 and an Abdim7? Hold on!) So how can you distinguish between a Bdim7 and a Ddim7, for instance?
There are two basic contexts in which the difference becomes apparent. The first is notational: Ddim7 is spelled D, F, Ab, Cb. Note that this, like any other seventh chord, preserves the "every other letter" pattern (assuming the musical alphabet to wrap around after G). Thus, for a diminished seventh, as for any seventh, the root is the only note for which every other note class is a third, a fifth, or a seventh above it (possibly moved up or down an octave or two, depending on the voicing). An E#dim7 would be E#, G#, B, D, and a G#dim7 would be G#, B, D, F.
The second is functional. The diminished seventh has a dominant function in a minor key. In C minor, for instance, you will typically see the Bdim7 (the leading tone diminished seventh) resolve to C- (the tonic minor). That role could also be played by G7 (the dominant seventh); this isn't surprising, given that both chords share B, D, and F in common, with the only difference being the G in G7 versus the Ab in Bdim7. This is why we have a Bdim7, a Ddim7, an Fdim7, but a G#dim7 rather than an Abdim7: A Bdim7 resolves to C- and a Ddim7 resolves to Eb-.
But Abdim7 would resolve to...what? One would like to say A-, but Ab isn't the leading tone of A-; G# is, so that's what the root of that diminished seventh "should" be. One might venture that Abdim7 could resolve to Bbb-, but Bbb isn't a tonic minor key in conventional music—at least not in anything that isn't trying explicitly to be at least a little weird. Likewise, an E#dim7 would resolve to F#-, so that's what we call it, an Fdim7 would resolve to Gb-, which, again, doesn't exist much. (As a tonic minor. It could be a secondary key.)
None of this has any impact on the sound of the chord, and so it may seem a little academic. But these regularities in the way that chords are notated makes it easier to make sense of them, and to remember how they form progressions.