Writing in the margins -- introduction
The columns of sifrei Torah, tefillin and mezuzah should be aligned along their right and left margins. Many Rishonim write that there should not be three or more letters, or a whole word of two letters, extending into the margins. According to the Rambam, it is permissible to have three or more letters in the margin as long as they comprise less than the majority of letters in the word [the word must be comprised of seven or more letters]. The poskim are divided in their understanding of Rambam's opinion as to whether two letters of a three-letter word can extend into the margin - i.e. whether he holds that it can be done, since he agrees that two letters in the margin do not invalidate the text, or whether he holds that it should be avoided, since in this case the two letters comprise the majority of the word. For the purpose of zeh keli v'anvehu (beautifying the mitzva), a sofer should avoid having any letters stick out into the margins.
(סעיף לג-לד, ס"ק קמז-קנא, וביה"ל ד"ה שלש וד"ה תיבה)