5. The number of different shapes of ellipses with eccentricity $e=\log _{p} q$ (where $p, q$ are positive integers not exceeding 9) is ( ).
(A) 26
(B) 27
(C) 28
(D) 30
5.A.

Given $0<e<1$, we know $2 \leqslant q<p \leqslant 9$.
For $p=3,4,5,6,7,8,9$, the corresponding $e$ values are $1,2,3$, $4,5,6,7$ respectively, totaling 28.

However, $\log _{3} 2=\log _{9} 4, \log _{4} 2=\log _{9} 3$, so there are 26 distinct $e$ values.
Editor's note: Similar ellipses have the same shape.