The T stands for "tubular", and the number is the diameter of the base in eighths of an inch. So a T8 bulb is 1" in diameter, and a T5 is 5/8 of an inch.
Technically the fixtures they fit is a matter of the base type; they make both T8s and T5s in various kinds of bases. But the T5s are generally much smaller and won't fit into the fixtures designed for T8s and vice versa.
As interest in energy saving technologies has grown and become popularized, these codes have come to designate levels of energy efficiency, instead of merely indicating lamp tube diameter.
Assumptions of Efficiency:
T12 = old and inefficient
T8 = higher efficiency
T5 = highest efficiency