Explanation for trends in size in the same period

The electrons on an atom are in orbitals.  The orbitals of similar energy are in shells which are labelled with a number known as the principal quantum number.

Electrons in shells with higher principal quantum numbers are on average farther from the nucleus.  
The cartoon shows a slice through an atom that has electrons in shells 1, 2 and 3.  
 
The size of an atom depends on how many shells are occupied and on the effective nuclear charge at the outer electrons. 
These two effects oppose one another.   
When comparing two atoms, the atom with more shells occupied is larger.
This means that atom size increases going down a group in the periodic table. 

When comparing two atoms, if the same number of shells are occupied (as for atoms in the same period),
the atom with the higher nuclear charge at the outer electrons is smaller.
However the decrease in size is not as great as would be expected because the outer electrons do not experience the full nuclear charge.
 
Why is the increase in effective nuclear charge at the outer electrons not as great as the actual increase in nuclear charge?
The effective nuclear charge at the outer electrons depends on
how many electrons are in the outer shell AND on how many electrons are in shells between the outer shell and the nucleus.

Electrons in the same shell reduce the effective nuclear charge because they repel one another. 

A set of guidelines known as Slater's rules puts this on a quantitative basis, but the numbers are not as important as the idea. 
 
Each electron in a shell closer to the nucleus cancels roughly 0.85 of the charge on one proton.
An estimate of the effective nuclear charge on the outer electron on Li (1s2 2s1) is +3 - 2 × 0.85 = +1.6

Each electron in the same shell cancels roughly 0.35 of the charge on one proton.
An estimate of the effective nuclear charge on an outer electron on Be (1s2 2s2) is +4 - 2 × 0.85 - 0.35 × 1 = +1.8
 
Atoms with outer electrons in the same shell, have a higher effective nuclear charge if their nuclear charge is larger. 
This means that atomic size decreases going across a period in the periodic table. 
For period 2:  Li  (1s2 2s1) > Be 1s2 2s> B 1s2 2s2p1 (effective nuclear charge 2.6)