this is also covered by the next section (on nested templates, view partials etc) which in turn contains many links into the forums - this will provide a wealth of alternative approaches.
It is also asked frequently (hence its presence here - duh!) on the forums -- about once every 36 hours on average, usually prefaced with the lie 'I couldn't find anything about how to do this...'. You're advised (read strongly encouraged) to use the forum search feature and Search in Titles Only for the words 'header' and 'footer'.