Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML How to Make a Website Creating HTML Content Use the Navigation Element

Placement of the <nav> element.

My question is more regarding the "nav" element itself.

In the video, the "nav" element is nested inside of the "header" tags, which prompted the following questions in my head:

1.) Was Nick's decision to place <nav> in the <header> tag best practice or a personal preference?

2.) Is there a situation where a designer would place the <nav> outside of the <header> vs. inside?

I do intend to try both once I log off for the evening, just wanted to get a sense of the pros vs. cons of doing so or if that was simply personal preference.

1 Answer

Chris Shaw
Chris Shaw
26,650 Points

Hi Rozario,

The choice to put the nav element in the header element would have come down to the design of the website and how certain elements needed to interact with each other along with some best practices, the nav element itself can be used anywhere within your code as it has no restrictions.

One thing this course didn't cover is the use of role attributes in which give meaning to elements such as nav allowing for specificity and basic accessibility support but you can read more about them at the below link.

http://www.w3.org/TR/role-attribute/

Thank you kindly! I will check out the link as well!