Short summary of the theory:
Trees are largely made of thin air ;-) : Carbon Dioxide provides the required (C)arbon, water that rains out of the air provides (H)ydrogen and (O)xygen, and (N)itrogen fixated from the air provides the basis for amino acids. This covers about 99% of the chemicals in the woody parts.
Young trees want to grow a lot, so they make a lot of lignin and cellulose. These consist of C, H, and O. Once trees have grown tall enough, they tend to slow down, so you'd expect them to not grab as much carbon anymore.