Since more than 240,000 people were killed in the 1976 Tangshan earthquake, Beijing has adopted building codes that analysts say are no less stringent than those in place in California and Japan.
But what's on the books here, and what gets followed and enforced, are sometimes two different matters, especially in poor rural areas.
Engineers who have worked in the mountainous region of the quake's epicenter, in Wenchuan County, say a lot of unregulated construction has taken place over the years. And that may help explain the horrific damage caused by Monday's magnitude 7.9 temblor, which has resulted in more than 12,000 deaths.
At least eight schools were flattened in the quake, including the three-story Juyuan Middle School in nearby Dujiangyan, where hundreds of students were buried. It was unclear whether the schools collapsed because they were too old, had faulty design or were constructed poorly or with cheap materials. Some of the schools may have been built before current seismic codes were enacted.
Many buildings in remote areas are low-rise structures that have drawn little attention from inspectors. The older buildings don't have substantial piers, experts said, and walls are still made of brick.
"Bigger cities are following and complying more seriously" with building codes, said James Yeh, the Shanghai manager for Gateway Engineering & Construction, a St. Louis-based company.
China's current seismic regulations contain detailed requirements for practically every type of structure, from one-story playhouses to multilevel apartments made of mud, wood and stone.
The nation's building codes don't have separate earthquake mandates for schools. Instead, structures are grouped into four classes, with each adhering to a certain intensity of seismic reinforcement, according to rules approved in 1999. Class 1 facilities include airports and nuclear reactors. The second highest class includes some hospitals, low-rise kindergarten buildings and elementary schools with large enrollments. Buildings that fall into Class 3, requiring ordinary seismic requirements, are most schools and apartment complexes.
"Schools should have more safety investments because students are more vulnerable," said Gao Jianguo, a geologist with China Earthquake Administration in Beijing.
Apart from the code, money is a problem, Gao said. "Unfortunately, right now, the education fund is not enough and many areas have more students but only a few old schools," he said.
The devastation triggered a rash of angry and cynical comments from citizens nationwide who viewed pictures of government buildings intact in the same towns where parents were wailing as the bodies of their children were pulled out of demolished schools.
"Why did so many schools collapse but all the government buildings were fine? It's outrageous!" wrote one online chat room participant in Beijing.
The south-central province of Sichuan where Monday's quake was centered suffered major quakes in 1933 and 1976. But the casualty numbers were considerably smaller.
Over the last decade, China's strong economic growth has spread inland, resulting in a burst of construction activity in rural areas. But as the heavy damage illustrates, the gap between China's countryside and urban centers appears to remain huge, not only in terms of income but also safety practices.
The floors of many buildings in rural areas are prefabricated slabs that are laid in place and quite often reused when a building is knocked down, said one longtime construction engineer in the region who requested anonymity.
"These would be free-floating during an earthquake as gravity keeps them in place, and as the walls sitting on them collapse, it would only get worse," he said.
Gao, the Beijing geologist, said a large number of houses that collapsed probably were put up by farmers themselves.
"Many worked their entire lives to build these houses," he said. "When construction materials became more expensive, many of them wouldn't consider earthquake resistance."
The average annual income in Wenchuan, population 112,000, was about $200 in 2002, the latest data available. That was less than one-fifth that of Chengdu, the capital of Sichuan province, about 60 miles southeast.
Chengdu and its 11 million residents were also rocked by the earthquake Monday afternoon. But despite the city's building boom in the last decade, it saw relatively little physical damage and its death toll was reported to be several hundred. One big reason: Many of the older factories and buildings in Chengdu, as in Beijing and Shanghai, were torn down and moved outside the city.
In larger cities, regulators have vigorously pushed most builders to adhere to strict earthquake standards.
William Gormley, a former China manager at Pratt & Whitney's joint venture in Chengdu, remembers what happened before Pratt began construction on its plant in 1996. Officials required the company to double the size of the piers, he said, and dig deeper into the ground to meet current seismic codes.
"All the plans were preapproved before we did the first shovel of dirt," said Gormley, who still works in Chengdu as a consultant. When the quake hit, he said, some ceiling tiles fell, but the 88,000-square-foot facility held up well.
Many other U.S. companies have operations in Chengdu, including Intel, Motorola and Microsoft. Both Microsoft and Motorola reported minor damage to their facilities.
Construction engineers said many high-rise buildings in Chengdu have earthquake dampers -- internal pendulums with heavy weights that damp movement in a quake.
But it was a different story in the remote towns to the north. In Dujiangyan, blocks of apartment buildings were flattened. Farther east, in Beichuan County, the official New China News Agency said 80% of the buildings were toppled.
Gormley, an engineer by training, remembers visiting those areas to cool off and fish in the mountain waters during Chengdu's hot summers.
"There're lots of unregulated buildings, many two and three stories with masonry construction, lots of brick," he said. "You don't find out how many until a tragedy like this happens."