Under the Tang dynasty, the paifang were used to delimit neighbourhoods (fangs). There were then 36 fangs in Beijing. Under the next dynasty (the Song), they had become purely decorative.