To travel into China most nationalities need a visa stuck into their passport. It is highly recommended that you search online for your nearest Chinese embassy or consulate and check carefully the current rules and regulations regarding visa issuance. To save time while travelling, it is wise to apply in your own country. Look on  first to check if your country is supported by an official application centre. If it isn't then use a search engine to locate a suitable visa agency if you cannot easily get to the Chinese diplomatic mission. 

Note that for immigration purposes, Hong KongMacau and Taiwan are not considered part of China. They have their own exit and entry protocols, including visa requirements. Flights or other passage between mainland China and any of these places are considered international journeys and these places are effectively treated as different countries. A Chinese visa specifies how many times you may enter the country as well as how long you can stay for. Options concerning this may be exercised during the application process. If you travel to any of these places from China you will have exited China so if you want to go back into China afterwards be sure you have been granted more than a single-entry.

As of August 2009, most nationalties can obtain a Chinese visa in Hong Kong from the visa office in Wanchai. There is a 'blacklist' of 33 countries including India, Indonesia  and South Africa for which passport holders might have to apply in their own country.

There is some info on applying (Oct 2010) for UK citizens in this thread: 

In the USA, the consulate in Houston has received good reports, while the New York Consulate is one to avoid. The consulate in LA is mostly used by agencies.  However, you can drop off your visa request in person in the morning and come back in the afternoon for same day service.  This was tested on a Tourist visa.  Note though that the consulate in LA is right next to Skid Row and not a generally nice area. Generally it is wise to use an agency in the USA as you are more likely to get a longer visa and more entries.

To apply for a tourist visa, in addition to your passport, you will generally need a completed visa application form, one recent passport sized photo and evidence of accommodation booking and flights or other passage in and out of the country. The documents required to support your visa application vary from country to country and are dependent upon the passport you hold. 

It is usually recommended that you apply for your visa 1 - 2 months before your intended travel. Tourist visas are normally valid for 3 months from the issue date for your first entry into China. After entering China you are then permitted to stay for the length of time indicated on your visa. If you apply too early, and even if you state clearly when your confirmed travel dates are, you may find that your visa has already expired. It is very important that you have a correct and valid visa. If you do not, it is likely that you will be refused entry at the border even if you are (mistakenly) permitted to board any transport to China. See this traveller's unfortunate experience:

When completing the itinerary section of the visa appication form do not mention Tibet. If you intend to travel there you will require a special permit and must join a tour group. This can be arranged before you arrive in China but it is not advised to mention this on your visa application.

For a longer visa, it is a good idea to write a long itinerary visiting many provinces. For tourist visas, length of entries are usually 30 or 60 days and occasionally 90 days or longer. You can extend a visa once and sometimes twice when in China at the local Public Security Bureau Entry-Exit Administration office for a fee, or if you have a double or multi entry, you can leave China by crossing the border at Hong Kong for example, and then return to start a new entry.

Normally it will take 4 working days to process an application. However, you can have the option of a second day pick-up or third day pick-up if you want to pay extra, or you may be able to complete your application by mail. Make sure your passport has a minimum validity of 6 months before the travel date.

You used to be able to obtain visas at Hong Kong Airport fairly quickly and easily. See: Hong Kong Airport China Visa .

NOTE (1):  Visa on arrival at Shenzhen / Zhuhai is possible for most nationalities - the main exception is American passport holders. Cost is 160 Rmb for most passport holders, but around 470 Rmb for British passport holders.

NOTE (2): Different visa issuing offices are interpreting these regulations in different ways. For example, for  Australians and Americans applying in their home country one year multi entry visas are quite common. For some other nationalities, single or double entry appear to be the maximum possible.