Actually, trees (and other plants) take in CO2 and give off oxygen.
Actually, they do both.
They ‘exhale’ O^2 during daylight; CO^2 at night. Generally, the younger they are, the greater the disparity between the two processes, though it “always” favors net O^2 production, while alive.
Living trees also contribute huge amounts of methane to the atmosphere; estimates range anywhere from 10% to 30% of annual atmospheric methane emissions.