nav element
Intro
The <nav>
element is used to wrap around navigation links.
A common use for the <nav>
element is the navigation menu at the top of a web page. Another use case could be a table of contents for a long blog post.
A web page can have more than one <nav>
element.
Steps
Create nav element
To create the <nav>
element, type <nav>
and then press Tab. Then press Enter, which should create a blank line in between the tags.
Create unordered list
Inside the nav element, type ul
and press Tab to create the <ul>
element. Then press Enter to create a blank line in between the tags.
Create list item elements
Inside the <ul>
element, type li
and press Tab to create a list item element. Then press Enter after the element to create a new line. Then repeat these steps again until you have 3 <li>
elements, just like below.
Create anchor elements
Inside each <li>
element, type a
and press Tab to generate an anchor element inside each one. This should create both tags with an href attribute in the opening tags.
Add link information
We want to link the Home, About, and Contact pages, so write these names inside each anchor element, just like the snippet below.
If you check the preview, you should see an unordered list with three links. However, the links don’t work yet.
To link to the home page, type a / inside the quotes. To link to the About and Contact pages, type the file names inside the quotes (about.html
and contact.html
).
Click on the links in the live preview to see if they are working correctly. Also, note that the <nav>
element won’t change the way the list or links look.
Final code
Check the last code snippet for the code that should be in between the body tags.