For the purpose of promoting health, safety, morals or the general welfare of the community, the legislative body of cities and incorporated towns may regulate and restrict the height, number of stories and size of buildings and other structures, percentage of lot that may be occupied, the size of yards, courts and other open spaces, the density of population, and the location and use of buildings, structures and land for trade, industry, residence or other purposes.