In 1924 Gichin Funakoshi, founder of Shotokan Karate, adopted the Dan ranking system, using a set of belt colors. Different styles of martial arts use various colors for their ranks. In the Kyu/Dan system the beginner grades start with a higher numbered Kyu and progress toward a lower Kyu (6th Kyu - 1st Kyu). The Dan ranks start with 1st Dan (Shodan) and continue to the higher Dan grades. Kyu grades are referred to as "color belts". Dan grades are referred to as black belts. Rank is earned through examination by a higher dan holder.
Requirements of rank differ amongst styles, organizations, and schools. Kyu ranks stress stance, balance, and coordination. Speed, power and accuracy are added at higher Kyu/Dan grades. Minimum age and time in rank are factors affecting promotion in the Dan ranks. Testing consists of a demonstration of techniques before a panel or your instructor. This will vary by school, but testing may include everything learned up to that point or just new information, and may include kata, bunkai, self-defense routines, and kumite (sparring).
Rank is to help the instructor to keep track of student progress and knowledge in their particular martial art. Many people use rank as a badge of honor but rank is a journey, not simply a destination. Keep in mind that Gichin Funakoshi had no rank and was referred to only as teacher.