The Tang dynasty (618-907) of ancient China witnessed many advancements in Chinese science and technology, with various developments in woodblock printing, timekeeping, mechanical engineering, medicine, structural engineering, cartography, and alchemy.
The popularization of woodblock printing during the Tang dynasty made the written word available to greater audiences. As a result of the much wider distribution and circulation of reading materials, the general populace were for the first time able to purchase affordable copies of texts, which correspondingly led to greater literacy. While the immediate effects of woodblock printing did not create a drastic change in Chinese society, in the long term, the accumulated effects of increased literacy enlarged the talent pool to encompass civilians of broader social-economic circumstances and backgrounds, who would be seen entering the imperial examinations and passing them by the later Song dynasty. The extent of woodblock printing is attested to by one of the world's oldest surviving printed documents, a miniature Buddhist dharani sutra unearthed at Xi'an in 1974, dating roughly from 650 to 670. A copy of the Diamond Sutra found at Dunhuang is the earliest surviving full-length book printed at regular size, complete with illustrations embedded within the text and dated precisely to 868. Among the earliest documents to be printed were Buddhist texts as well as calendars, the latter essential for calculating and marking which days were auspicious and which days were not. The commercial success and profitability of woodblock printing was attested to by one British observer at the end of the nineteenth century, who noted that even before the arrival of western printing methods, the price of books and printed materials in China had already reached an astoundingly low price compared to what could be found in his home country. Of this, he said:
We have an extensive penny literature at home, but the English cottager cannot buy anything like the amount of printed matter for his penny that the Chinaman can for even less. A penny Prayer-book, admittedly sold at a loss, cannot compete in mass of matter with many of the books to be bought for a few cash in China. When it is considered, too, that a block has been laboriously cut for each leaf, the cheapness of the result is only accounted for by the wideness of sale.
Although Bi Sheng later invented the movable type system in the 11th century, Tang dynasty style woodblock printing would remain the dominant mode of printing in China until the more advanced printing press from Europe became widely accepted and used in East Asia. However it was not Gutenberg's letterpress that made the decisive breakthrough for Western methods in China as it is commonly believed, but lithography, a nineteenth century technological marvel almost wholly forgotten in Europe.
Playing cards may have been invented during the Tang dynasty around the 9th century AD as a result of the usage of woodblock printing technology. The first possible reference to card games comes from a 9th-century text known as the Collection of Miscellanea at Duyang, written by Tang dynasty writer Su E. It describes Princess Tongchang, daughter of Emperor Yizong of Tang, playing the "leaf game" in 868 with members of the clan of Wei Baoheng, the family of the princess' husband.:131 The first known book on the "leaf" game was called the Yezi Gexi and allegedly written by a Tang woman. It received commentary by writers of subsequent dynasties. The Song dynasty (960-1279) scholar Ouyang Xiu (1007-1072) asserts that the "leaf" game existed at least since the mid-Tang dynasty and associated its invention with the development of printed sheets as a writing medium. However, Ouyang also claims that the "leaves" were pages of a book used in a board game played with dice, and that the rules of the game were lost by 1067.
Other games revolving around alcoholic drinking involved using playing cards of a sort from the Tang dynasty onward. However these cards did not contain suits or numbers. Instead, they were printed with instructions or forfeits for whoever drew them.
The earliest dated instance of a card game involving cards with suits and numerals occurred on 17 July 1294 when "Yan Sengzhu and Zheng Pig-Dog were caught playing cards [zhi pai] and that wood blocks for printing them had been impounded, together with nine of the actual cards."
William Henry Wilkinson suggests that the first cards may have been actual paper currency which doubled as both the tools of gaming and the stakes being played for, similar to trading card games. Using paper money was inconvenient and risky so they were substituted by play money known as "money cards". One of the earliest games in which we know the rules is Madiao, a trick-taking game, which dates to the Ming Dynasty (1368-1644). Fifteenth century scholar Lu Rong described it is as being played with 38 "money cards" divided into four suits: 9 in coins, 9 in strings of coins (which may have been misinterpreted as sticks from crude drawings), 9 in myriads (of coins or of strings), and 11 in tens of myriads (a myriad is 10,000). The two latter suits had Water Margin characters instead of pips on them :132 with Chinese characters to mark their rank and suit. The suit of coins is in reverse order with 9 of coins being the lowest going up to 1 of coins as the high card.
Technology during the Tang period was built also upon the precedents of the past. The mechanical gear systems of Zhang Heng (78-139) and Ma Jun (fl. 3rd century) gave the Tang engineer, astronomer, and monk Yi Xing (683-727) inspiration when he invented the world's first clockwork escapement mechanism in 725. This was used alongside a clepsydra clock and waterwheel to power a rotating armillary sphere in representation of astronomical observation. Yi Xing's device also had a mechanically timed bell that was struck automatically every year, and a drum that was struck automatically every quarter-hour; essentially, a striking clock. Yi Xing's astronomical clock and water-powered armillary sphere became well known throughout the country, since students attempting to pass the imperial examinations by 730 had to write an essay on the device as an exam requirement. However, the most common type of public and palace timekeeping device was the inflow clepsydra. Its design was improved c. 610 by the Sui-dynasty engineers Geng Xun and Yuwen Kai. They provided a steelyard balance that allowed seasonal adjustment in the pressure head of the compensating tank and could then control the rate of flow for different lengths of day and night.
There were many other mechanical inventions during the Tang era. This included a 0.91 m (3 ft) tall mechanical wine server of the early 8th century that was in the shape of an artificial mountain, carved out of iron and rested on a lacquered-wooden tortoise frame. This intricate device used a hydraulic pump that siphoned wine out of metal dragon-headed faucets, as well as tilting bowls that were timed to dip wine down, by force of gravity when filled, into an artificial lake that had intricate iron leaves popping up as trays for placing party treats. Furthermore, as the historian Charles Benn describes it:
Midway up the southern side of the mountain was a dragon...the beast opened its mouth and spit brew into a goblet seated on a large [iron] lotus leaf beneath. When the cup was 80% full, the dragon ceased spewing ale, and a guest immediately seized the goblet. If he was slow in draining the cup and returning it to the leaf, the door of a pavilion at the top of the mountain opened and a mechanical wine server, dressed in a cap and gown, emerged with a wooden bat in his hand. As soon as the guest returned the goblet, the dragon refilled it, the wine server withdrew, and the doors of the pavilion closed...A pump siphoned the ale that flowed into the ale pool through a hidden hole and returned the brew to the reservoir [holding more than 16 quarts/15 liters of wine] inside the mountain.-- 
Although the use of a teasing mechanical puppet in this wine-serving device was certainly ingenious, the use of mechanical puppets in China date back to the Qin dynasty (221-207 BC) while Ma Jun in the 3rd century had an entire mechanical puppet theater operated by the rotation of a waterwheel. There was also an automatic wine-server known in the ancient Greco-Roman world, a design of Heron of Alexandria that employed an urn with an inner valve and a lever device similar to the one described above. There are many stories of automatons used in the Tang, including general Yang Wulian's wooden statue of a monk who stretched his hands out to collect contributions; when the amount of coins reached a certain weight, the mechanical figure moved his arms to deposit them in a satchel. This weight-and-lever mechanism was exactly like Heron's penny slot machine. Other devices included one by Wang Ju, whose "wooden otter" could allegedly catch fish; Needham suspects a spring trap of some kind was employed here.
The Chinese of the Tang era were also very interested in the benefits of officially classifying all of the medicines used in pharmacology. In 657, Emperor Gaozong of Tang (r. 649-683) commissioned the literary project of publishing an official materia medica, complete with text and illustrated drawings for 833 different medicinal substances taken from different stones, minerals, metals, plants, herbs, animals, vegetables, fruits, and cereal crops. In addition to compiling pharmacopeias, the Tang fostered learning in medicine by upholding imperial medical colleges, state examinations for doctors, and publishing forensic manuals for physicians. Authors of medicine in the Tang include Zhen Qian (d. 643) and Sun Simiao (581-682), the former who first identified in writing that patients with diabetes had an excess of sugar in their urine, and the latter who was the first to recognize that diabetic patients should avoid consuming alcohol and starchy foods. As written by Zhen Qian and others in the Tang, the thyroid glands of sheep and pigs were successfully used to treat goiters; thyroid extracts were not used to treat patients with goiter in the West until 1890.
In the realm of technical Chinese architecture, there were also government standard building codes, outlined in the early Tang book of the Yingshan Ling (National Building Law). Fragments of this book have survived in the Tang Lü (The Tang Code), while the Song architectural manual of the Yingzao Fashi (State Building Standards) by Li Jie (1065-1101) in 1103 is the oldest existing technical treatise on Chinese architecture that has survived in full. During the reign of Emperor Xuanzong of Tang (712-756) there were 34,850 registered craftsmen serving the state, managed by the Agency of Palace Buildings (Jingzuo Jian).
In the realm of cartography, there were further advances beyond the map-makers of the Han dynasty. When the Tang chancellor Pei Ju (547-627) was working for the Sui dynasty as a Commercial Commissioner in 605, he created a well-known gridded map with a graduated scale in the tradition of Pei Xiu (224-271). The Tang chancellor Xu Jingzong (592-672) was also known for his map of China drawn in the year 658. In the year 785 the Emperor Dezong had the geographer and cartographer Jia Dan (730-805) complete a map of China and her former colonies in Central Asia. Upon its completion in 801, the map was 9.1 m (30 ft) in length and 10 m (33 ft) in height, mapped out on a grid scale of one inch equaling one hundred li (Chinese unit of measuring distance). A Chinese map of 1137 is similar in complexity to the one made by Jia Dan, carved on a stone stele with a grid scale of 100 li. However, the only type of map that has survived from the Tang period are star charts. Despite this, the earliest extant terrain maps of China come from the ancient State of Qin; maps from the 4th century BC that were excavated in 1986.
The Chinese of the Tang period employed complex chemical formulas for an array of different purposes, often found through experiments of alchemy. These included a waterproof and dust-repelling cream or varnish for clothes and weapons, fireproof cement for glass and porcelain wares, a waterproof cream applied to silk clothes of underwater divers, a cream designated for polishing bronze mirrors, and many other useful formulas. The vitrified, translucent ceramic known as porcelain was invented in China during the Tang, although many types of glazed ceramics preceded it.
Ever since the Han dynasty (202 BC - 220 AD), the Chinese had drilled deep boreholes to transport natural gas from bamboo pipelines to stoves where cast iron evaporation pans boiled brine to extract salt. During the Tang dynasty, a gazetteer of Sichuan province stated that at one of these 182 m (600 ft) 'fire wells', men collected natural gas into portable bamboo tubes which could be carried around for dozens of km (mi) and still produce a flame. These were essentially the first gas cylinders; Robert Temple assumes some sort of tap was used for this device.
The inventor Ding Huan (fl. 180 AD) of the Han dynasty invented a rotary fan for air conditioning, with seven wheels 3 m (10 ft) in diameter and manually powered. In 747, Emperor Xuanzong had a "Cool Hall" built in the imperial palace, which the Tang Yulin () describes as having water-powered fan wheels for air conditioning as well as rising jet streams of water from fountains. During the subsequent Song dynasty, written sources mentioned the air conditioning rotary fan as even more widely used.