Atomic weight is the weight of atoms of an element. The science behind this measurement is extremely complex, and it has changed quite a bit since the early 1800s, when the concept was first proposed. It is also important to distinguish between weight and mass: atomic weight, also called relative atomic mass, reflects the average weight of a single atom of an element, while atomic mass refers to the weight of a specific atom.
Simple textbooks and science courses often describe atomic weight as the number of protons and neutrons in an element added together. An element with two protons and two neutrons, for example, would be considered to have a weight of four under this system. Unfortunately, neutrons actually weigh more than protons, which makes this rough guideline a bit inaccurate.
Individual atoms are extremely small, and rather challenging to weigh on their own. Early researchers arrived at a system that involved determining the weight of an element relative to the weight of another. Several benchmark elements were proposed, including hydrogen, with the current measurements being derived from carbon-12, a stable and abundant form of carbon. An atomic mass unit, the unit of measurement used to arrive at atomic weight, consists of 1/12 the weight of carbon-12.
There's another complexity to add to the equation, which is that most elements exist in the form of multiple isotopes, each of which has a slightly different mass. Measurements of relative atomic mass actually reflect an average of the measurements taken from samples of all of the known isotopes of an element. In the case of elements with only one or two known isotopes, the weight is often very close to a whole number, but in the case of other elements, the exact measurement can add quite a few digits after the decimal point.
The International Union of Pure and Applied Chemistry regularly publishes lists of atomic weights that are used as standards in the scientific community. For quickie calculations, especially in very basic introductory science classes, the old “protons plus neutrons” formula is sometimes used, but in the advanced sciences, it is important to use a more precise measurement. Especially finicky scientists may actually take the time to determine the specific atomic mass of an element they are working with, as minor variations between isotopes can make a huge differences in experiments.