All fences or enclosures of land shall be substantially constructed, whether with rails, logs, post and railing, iron, steel, or other material, and not less than 5 feet high; to the extent of 2 feet from the ground there shall not be a space between the material used in the construction of any fence greater than 4 inches; provided, that when any fence or enclosure shall be made with a trench or a ditch, the same shall be 4 feet wide; and in that case the fence shall be 5 feet high from the bottom of the ditch to the top of the fence.