nav
In this module we will discuss the <nav>
tag.
File Location
For this module, you should be working in the following location:
Description:
The <nav>
tag is typically used to collect a set of navigation links. This is not intended to suggest that every link in your application should be encapsulated inside of a <nav>
. The links collected in a <nav>
are usually used to traverse through different pages in your application, usually in a navbar at the top of your application.
Sample Code
Add the following sample code to your file:
Discussion
We've provided two examples above, but there are innumerable ways to accomplish this task, and the needs of the application may demand a specific solution. The first example is typical and produces a horizontally-aligned navbar. In the second example, we've specified that the browser should render the navbar vertically as an unordered list by using <ul>
and <li>
tags.
Challenge
Try adding new links to your navbar. Experiment with the href
attribute and try navigating to an outside webpage. Try adding an attribute to keep your webpage open and open the linked page in a new tab. Check out the code in lesson 4 if you need a refresher.(hint: it's in the "target" portion of the lesson)
Extra Reading:
Last updated