You cannot expect a treatise on stellar atmospheres and the estimate of stellar abundances in a Physics SE answer, but here is a brief sketch.
The atmosphere of a star can be approximated in terms of a plane, parallel slab, with gradients of temperature and density in the "vertical" (the direction in which gravity acts) direction. The structure of this slab is deduced using an equation of state, the equation of hydrostatic equilibrium and a prescription for energy transport (usually approximated to be carried by radiative diffusion).
Having setup your stellar atmosphere, you can ask what the emergent spectrum of radiation will be. To first-order, the spectrum is a blackbody at the temperature of the layer from which the photons are able to escape. How deep and hot that layer is, will depend on the opacity of the overlying material. This is wavelength-dependent; if there is say an atomic transition at some wavelength, then that will be more opaque. By exactly how much requires quantum mechanical calculations of how an atom interacts with radiation at any given wavelength.
At wavelengths where there are atomic transitions present, and the opacity is high, then the emergent radiation comes from a higher, cooler layer, and is less bright as a result. This is the phenomenon that gives rise to dark(er) "absorption lines" (see Formation of emission lines, absorption spectra ). The strength of an absorption line (i.e. how deep and wide it is in the spectrum) will depend on the details of the atmospheric structure, the atomic physics of the transition and the number of atoms of that particular element along the line of sight through the atmosphere. This latter quantity is closely related to the relative abundance of the element (to hydrogen) causing the transition.
Armed with a theoretical prediction of how strong absorption lines are as a function of the relative abundance of an element, one can compare the strengths of many absorption lines, for many elements, against an observed spectrum. This allows you to infer the "stellar parameters" - basically the effective temperature and gravity of the stellar atmosphere and the relative abundances of any chemical elements observed in that atmosphere.
The next step is to make some estimate or assumption about whether the abundance ratios you meaure in the stellar atmosphere are the same in the stellar interior. To first order, they are. Stars are generally well-mixed. However, there are (theoretical) corrections that can be made, particularly with respect to the abundance of helium, which alone of the chemical elements, is being manufactured in great quantities in the stellar core.
From these considerations you can arrive at the relative abundances (and hence the mass fractions) of hydrogen and any chemical elements you can measure in the Sun's atmosphere.
I have to tell you though that this is not where the 71% figure comes from. That is a prediction based on stellar evolutionary models and our knowledge of nuclear physics and the age of the Sun (from meteorites). A major observational uncertainty in trying to do it the way I described above, would be how much helium the Sun actually possesses. It cannot easily be measured in the solar atmosphere (there are no observed helium atomic transitions in the visible part of the solar spectrum, because the photosphere is too cool to populate the lower energy levels of these transitions) and it will vary with depth in any case. The way one tests and checks a theoretical helium production rate and abundance is through observations of the neutrino flux from the Sun, which tell us how fast the nuclear reactions are proceeding and through helioseismology observations of the Sun's oscillations, which are also sensitive to the amount of helium and its stratification.
The situation is better for determining the ratios of heavier elements to hydrogen, but these make up the minority (~1%) of the solar mass. Even there, we have a cross-check by looking at the relative abundances of elements heavier than helium in meteorites. These should be similar to the solar composition since elements heavier than helium are neither created or destroyed (bar lithium) in any signficant quantity.