שולחן ערוך, יורה דעה שס״ז
Shulchan Arukh, Yoreh De'ah 367
קוברים מתי עכו"ם ושלא יהלך בבית הקברות בתפילין וציצית. ובו ו' סעיפים:
קוברים מתי עכו"ם ומנחמים אבליהם מפני דרכי שלום:
קוברים מתי עכו"ם ומנחמים אבליהם מפני דרכי שלום:
One buries the dead of the Gentiles and comforts their mourners in the interests of peace.
לא יהלך בבית הקברות או בתוך ד' אמות של מת ותפילין בראשו משום לועג לרש ואם הם מכוסים מותר:
One may not walk on the cemetery or within four cubits of a corpse while [wearing] phylacteries on his head, on account of, 'Whoso mocketh the poor blasphemeth his Maker'. But if they are covered it is permitted.
לא יהלך בבית הקברות או בתוך ד' אמות של מת או של קבר וספר תורה בזרועו ויקרא בו או יתפלל והוא הדין על פה אסור לקרות אלא אם כן לכבוד המת כמו שנתבאר (וע"ל סימן שד"מ סעיף ט"ז):
One may not walk on the cemetery or within four cubits of a corpse or a grave while [holding] a Torah scroll in his arm and read in it, [nor] may one recite the Tefillah [there]. Likewise, is it forbidden to recite [Biblical verses] orally [on the cemetery], unless it is for the honour of the dead as has been explained.
מותר ליכנס לבית הקברות או לתוך ד' אמות של מת או של קבר והוא לבוש ציצית והוא שלא יהא נגרר על הקבר אבל אם נגרר אסור משום לועג לרש במה דברים אמורים בימיהם שהיו מטילים ציצית במלבוש שלובשים לצורך עצמן אבל האידנא שאין אנו לובשין אותו אלא לשם מצוה אסור אפי' אינם נגררים והני מילי כשהציציות מגולים אבל אם הם מכוסים מותר:
One is permitted to enter the cemetery, or within four cubits of a corpse or a grave [while] wearing Ẓizith, provided it is not dragged along over the grave; but if it is dragged along, it is forbidden on account of, 'Whoso mocketh the poor'. When does this apply? — only in their days when they used to attach Ẓizith to the garment which they wore for their personal need, but today, since we wear it only for the sake of the religious duty, it is prohibited, even if they are not dragged along. And this is the case only if the Ẓizith are uncovered, but if they are covered, it is permitted.
יש נוהגין לקשור שני ציציות שבשני כנפים זה עם זה כשנכנסים לבית הקברות ולא הועילו כלום בתקנתם (ועיין בא"ח סימן כ"ג):
Some follow the practice to tie together two Ẓizith from two corners [of the garment] when entering the cemetery, but they have profited nothing by their measure.
כיון שהרחיק ד' אמות קורא ומתפלל ואפילו רואה הקבר או בית הקברות ואם יש שם מחיצה מותר אחר המחיצה סמוך אפילו תוך ד' אמות לקבר:
As soon as one removes himself four cubits he may read [the Shema] and recite the Tefillah even if he [still] sees the grave or the cemetery; and if there is a partition there, he is permitted [to read the Shema and recite the Tefillah] behind the partition close by, even within four cubits of the grave.
Ashlei Ravrevei: Shulchan Aruch Yoreh Deah, Lemberg, 1888 (Public Domain) · Code of Hebrew Law by Chaim N. Denburg, Montreal, 1955 (CC-BY) · 6 se'ifim