Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Matthew Francis
Matthew Francis
6,967 Points

Do we need <header> / <footer> inside the <body>? What happens if we don't create <body>, are all these for semantics?

Does the browser actually read it and make loading faster or something? or is this just good practice so other devs can read it?

1 Answer

Cooper Runstein
Cooper Runstein
11,850 Points

They're technically optional, but body is pretty much in every single html page you'll run across, and there's no chance you'd be allowed to omit it if you're working on a team. Header/footer are a little more subjective, I almost always make a <div> with a class named header or footer.

Matthew Francis
Matthew Francis
6,967 Points

Ahh so it's mostly semantics? Is it better pracice to remove header and footer with <div>?

Cooper Runstein
Cooper Runstein
11,850 Points

It depends. It is semantics, but it's also common practice, so if you want write html in a professional setting you might be required to add them in there. I use divs because I like to run a really rough css 'reset' on my divs to make sure none of the browser defaults are left, but quite frankly it's better practice to use header and footers and I'm just lazy. The main reason for this is accessiblity, tools that come to your website and read through the page look for these semantic tags to figure out where things are -- which is why tags like nav are good to use, despite the fact that I rarely do. But also be aware that most companies, where I work included, have style guides and can and do enforce these things, in your personal projects your preference trumps all else on somewhat trivial issues like this.