סימן יא סעיף ה
מְקוֹמָהּ מִתְּחִלַּת שְׁלִישׁ הָעֶלְיוֹן שֶׁל גֹּבַהּ הַשָּׁעַר. קְבָעָהּ לְמַעְלָה מִזֶּה, כְּשֵׁרָה, וְהוּא שֶׁיַּרְחִיקֶנָּה מִן הַמַּשְׁקוֹף טֶפַח. קְבָעָהּ לְמַטָּה מִשְּׁלִישׁ הָעֶלְיוֹן, צָרִיךְ לַהֲסִירָהּ וּלְקָבְעָהּ כָּרָאוּי וּבִבְרָכָה. וְאִם קְבָעָהּ בְּטֶפַח הָעֶלְיוֹן, יְסִירָה גַּם כֵּן וְיִקְבְּעֶהָ כָּרָאוּי, אֲבָל לֹא יְבָרֵךְ. וְיֵשׁ לְקָבְעָהּ בְּטֶפַח הַסָּמוּךְ לַחוּץ. וְאִם שִׁנָּה בָזֶה, אֵינוֹ מְעַכֵּב (רפ"ט).
The mezuzah must be affixed at the beginning of the upper third of the height of the door-post. If you affix it higher than this, it is also valid providing it is distanced at least one tefach2See Glossary. [handbreadth] away from the lintel. If you affixed the mezuzah below the upper third of the doorpost, you must remove the mezuzah and reaffix it in the proper manner and recite the berachah. If you placed the mezuzah within the uppermost tefach, you should also remove it and reaffix it properly, but without reciting the berachah. It is best to affix the mezuzah within the tefach closest to the outside of the door-post, but if you deviate from this rule the basic fulfillment of the mitzvah is unaffected.
תנא דבי אליהו כל השונה הלכות בכל יום מובטח לו שהוא בן העולם הבא שנאמר הליכות עולם לו אל תקרי הליכות אלא הלכות (נדה ע"ג.)