1<!-- How to create a navigation bar:
2 This is the html file:
3
4 Put the class="active" in the html file/page you are coding in
5 (e.g. put the class="active" in the Home.html file)
6 To position a page link to the right do class="right"
7-->
8<body>
9<ul class="topnav">
10 <li><a class="active" href="Home.html">Home</a></li>
11 <li><a href="Page1.html">Page1</a></li>
12 <li><a href="Page2.html">Page2</a></li>
13 <li class="right" ><a href="About.html">About</a></li>
14</ul>
15</body>
16
17<!-- This is the css file:
18 (have a play with the colours and features!)-->
19ul.topnav {
20 list-style-type: none;
21 margin: 0;
22 padding: 0;
23 overflow: hidden;
24 background-color: #333;
25 font-family: arial;
26 text-align: left;
27 width: 100%;
28 position: sticky;
29 top: 0;
30}
31ul.topnav li {float: left;}
32ul.topnav li a {
33 display: block;
34 color: white;
35 text-align: center;
36 padding: 14px 16px;
37 text-decoration: none;
38 float: left;
39 font-size: 17px;
40 border-right: 1px solid #bbb;
41}
42ul.topnav li a:hover:not(.active) {
43 background-color: #ddd;
44 color: black;
45}
46ul.topnav li a.active {
47 background-color: #4CAF50;
48}
49ul.topnav li.right {
50 float: right;
51}
52@media screen and (max-width: 720px) {
53 ul.topnav li{
54 width: 100%;
55 }
56 ul.topnav a{
57 width: 100%;
58 }
59}
60<!-- END -->
1<nav class="navbar navbar-expand-lg navbar-light bg-light">
2 <a class="navbar-brand" href="#">Navbar</a>
3 <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
4 <span class="navbar-toggler-icon"></span>
5 </button>
6
7 <div class="collapse navbar-collapse" id="navbarSupportedContent">
8 <ul class="navbar-nav mr-auto">
9 <li class="nav-item active">
10 <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
11 </li>
12 <li class="nav-item">
13 <a class="nav-link" href="#">Link</a>
14 </li>
15 <li class="nav-item dropdown">
16 <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
17 Dropdown
18 </a>
19 <div class="dropdown-menu" aria-labelledby="navbarDropdown">
20 <a class="dropdown-item" href="#">Action</a>
21 <a class="dropdown-item" href="#">Another action</a>
22 <div class="dropdown-divider"></div>
23 <a class="dropdown-item" href="#">Something else here</a>
24 </div>
25 </li>
26 <li class="nav-item">
27 <a class="nav-link disabled" href="#">Disabled</a>
28 </li>
29 </ul>
30 <form class="form-inline my-2 my-lg-0">
31 <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
32 <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
33 </form>
34 </div>
35</nav>
1<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
2 <div class="container-fluid">
3 <a class="navbar-brand" href="#">Navbar</a>
4 <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
5 <span class="navbar-toggler-icon"></span>
6 </button>
7 <div class="collapse navbar-collapse" id="navbarSupportedContent">
8 <ul class="navbar-nav me-auto mb-2 mb-lg-0">
9 <li class="nav-item">
10 <a class="nav-link active" aria-current="page" href="#">Home</a>
11 </li>
12 <li class="nav-item">
13 <a class="nav-link" href="#">Link</a>
14 </li>
15 <li class="nav-item dropdown">
16 <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
17 Dropdown
18 </a>
19 <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
20 <li><a class="dropdown-item" href="#">Action</a></li>
21 <li><a class="dropdown-item" href="#">Another action</a></li>
22 <li><hr class="dropdown-divider"></li>
23 <li><a class="dropdown-item" href="#">Something else here</a></li>
24 </ul>
25 </li>
26 <li class="nav-item">
27 <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
28 </li>
29 </ul>
30 <form class="d-flex">
31 <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
32 <button class="btn btn-outline-success" type="submit">Search</button>
33 </form>
34 </div>
35 </div>
36</nav>
1<ul class="nav nav-tabs" id="myTab" role="tablist">
2 <li class="nav-item">
3 <a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
4 </li>
5 <li class="nav-item">
6 <a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
7 </li>
8 <li class="nav-item">
9 <a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
10 </li>
11</ul>
12<div class="tab-content" id="myTabContent">
13 <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
14 <div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
15 <div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
16</div>
1<nav class="navbar navbar-expand-lg navbar-light bg-light">
2 <div class="container-fluid">
3 <a class="navbar-brand" href="#">Navbar</a>
4 <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
5 <span class="navbar-toggler-icon"></span>
6 </button>
7 <div class="collapse navbar-collapse" id="navbarSupportedContent">
8 <ul class="navbar-nav me-auto mb-2 mb-lg-0">
9 <li class="nav-item">
10 <a class="nav-link active" aria-current="page" href="#">Home</a>
11 </li>
12 <li class="nav-item">
13 <a class="nav-link" href="#">Link</a>
14 </li>
15 <li class="nav-item dropdown">
16 <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
17 Dropdown
18 </a>
19 <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
20 <li><a class="dropdown-item" href="#">Action</a></li>
21 <li><a class="dropdown-item" href="#">Another action</a></li>
22 <li><hr class="dropdown-divider"></li>
23 <li><a class="dropdown-item" href="#">Something else here</a></li>
24 </ul>
25 </li>
26 <li class="nav-item">
27 <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
28 </li>
29 </ul>
30 <form class="d-flex">
31 <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
32 <button class="btn btn-outline-success" type="submit">Search</button>
33 </form>
34 </div>
35 </div>
36</nav>