The periods (rows) correspond to the energy levels where electrons are found in atoms.
The first energy level (just an s sublevel) can hold up to two electrons. This period contains only two elements; H and He.
The second energy level can hold up to 8 electrons (s and p sublevels) so this period has eight elements; Li, Be, B, C, N, O, F and Ne.
The third energy level can hold up to 18 electrons (s, p and d sublevels).
Here it gets a little tricky, the 3d orbital does not fill until after the 4s orbital. The third period still contains only 8 elements (Na - Ar) because the third period contains the 3s and 3p sublevels.
The fourth period (K-Kr) has 18 elements and contains the following sublevels; 4s, 3d and 4p.
The 5th period also has 18 elements (Rb - Xe) and contains the following sublevels; 5s, 4d and 5p.
The fourth energy level can hold 32 electrons (s,p,d and f sublevels)
The 6th and 7th periods have 32 elements.
Period 6 (Cs-Rn) includes elements in the Lanthanide series (La-Yb) and includes the sublevels; 6s, 4f, 5d, 6p