What could be causing the navigation bar to not display properly in Bootstrap?

While attempting to create a navbar with Bootstrap, I encountered an error. The expected result should be a navbar, but instead it is not displaying correctly. In an effort to understand the nature of the error, I copied the code from W3schools (available at https://www.w3schools.com/bootstrap/bootstrap_navbar.asp) into my Atom editor. Surprisingly, both my code and W3schools' code are not functioning as expected, even though they appear to be correctly written. I am puzzled as to where I may have gone wrong. Could you please offer your assistance?

Here is the code I am using:

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title></title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">


  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>

  <body>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>

    <nav class=“navbar”>

      <nav class="navbar">
        <a class="navbar-brand" href=“#”>Something</a>
        <ul class="navbar-nav">
          <li class="nav-item"><a href="#" class="nav-link">One</li>
    </ul>
</nav>
</body>
</html>

Answer №1

Prior to integrating bootstrap into your project, it is advisable to first include jquery... Here is an example:

<script src="http://code.jquery.com/jquery-latest.min.js"></script>

Answer №2

Make a simple adjustment to your text-formatted quotes like so.

 <header class=“header”>

Change them to non-text formatted quotes.

 <header class="header">

Answer №3

Your code is currently utilizing Bootstrap 4.x, the latest release which has significant differences compared to Bootstrap 3.x. Although there may be similarities, it is important to note that anything functioning in 3.x may not work as expected in 4.x.

Instead of relying on W3School's code, it is recommended to refer to Twitter Bootstrap's official documentation for version 4.0: https://getbootstrap.com/docs/4.0/getting-started/introduction/

Furthermore, there are some errors in your HTML code, such as the missing closing tag in this line:

<li class="nav-item"><a href="#" class="nav-link">One</li>

It is crucial to review your code for syntax errors, as they can cause unexpected issues. By correcting these errors and following Bootstrap 4's guidelines, you can achieve the desired output, such as a properly structured navbar:

https://getbootstrap.com/docs/4.0/components/navbar/

Additionally, ensure that jQuery is loaded before bootstrap.min.js, as Bootstrap's JavaScript functionality depends on jQuery.

Best of luck with your coding endeavors.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The text following a table is spilling into the table because it is too big to fit within the designated div

I've been searching for a solution to this issue (it's a common problem), but nothing I've attempted has resolved it. Currently, I am using jQuery Mobile. Below is the code snippet in question: <div style="width:100%; height:220px;"> ...

IE encountered an invalid character

While working on a JavaScript function, I encountered an issue with a string variable. Specifically, when running the page in IE with this script, I receive an error message indicating an invalid character at the following line: let displayString = `${s ...

Bootstrap not functioning properly in selecting gallery items

Looking for some help with my website's gallery page development. I've included the HTML and JavaScript files below. However, I seem to be missing a selector ID as none of the pictures are changing and the categories aren't working. Any help ...

Create a custom div class specifically designed for an image button

Apologies if my title is a bit misleading, I struggled to find the right phrasing. Currently, I have images linked to various social networks using href. For instance, clicking on the facebook icon directs to my Facebook page. The layout looks like this: ...

"Choosing the text within an <a> tag: A step-by

I am dealing with the a tag. <a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c7dbd9d1f4d9d5ddd89ad7dbd9">[email protected]</a>"><a href="/cdn-cgi/l/email-protection" class="__cf_email__" ...

Hover function not functioning properly

I can't figure out why this hover effect isn't working, there doesn't seem to be a negative z-index or anything like that. At most, it just flashes on hover; .menu{ border-radius: 50%; width: 100px; height: 100px; background: white; box-sha ...

Scraping Data: Uncover JSON data embedded in HTML code

I need help extracting what appears to be JSON data embedded within an HTML script. The script is presented like this on the webpage: <script> $(document).ready(function(){ var terms = new Verba.Compare.Collections.Terms([{"id":"6436","name ...

Modify the click function from <tr> to <td> tag

I want to create an HTML page that functions as a digital library for books. Users should be able to click on a rate button to save the selected book to local storage, allowing them to see their rating whenever they revisit the page. However, I'm enc ...

What is the best way to organize angularjs controllers and directives within one another?

When I structure my controllers like this: <body ng-app="app" ng-controller="ctrl"> <div ng-controller="app-get"> <app-get></app-get> </div> <div ng-controller="app-post"> <app-post">& ...

The Server-Sent Event feature seems to be malfunctioning as it appears that browsers are unable to detect any events sent through Server-Sent

I have successfully implemented server-sent events (HTML5) in my project without using node.js. It is a simple webpage (another JSP page) that makes a call and receives a response. However, when I receive the response, none of the methods/functions (onopen ...

Is there a way to divide this constantly changing list into 3 separate columns?

I'm currently tackling updates on an older web application, and instead of completely rewriting everything to conform to modern standards, I am endeavoring to keep the changes as straightforward as possible. Displayed below is a dynamically generated ...

Why is it that @font-face fails to function properly even after being defined correctly?

Here's the @font-face code I've been using: @font-face { font-family: "NotesEsa-Bold"; src: url("C:\Users\test\Desktop\Webpage\Fonts\NotesEsaBol.ttf") format("truetype"); /* Safari, Android, iOS */ font-we ...

Apply a box-shadow to the lower part of the div starting from the center

After much searching, I finally found a preview of what I had in mind. Unfortunately, I couldn't find the right words to describe it. Here is the link to the image for reference: https://i.sstatic.net/t2q27.png Thank you in advance for your help. ...

Set the input of a component in Angular to determine its width

I am working on a basic angular component. Here is the code snippet: <div class="k-v-c" fxFlex fxLayout = "row" > <div class="k-c" fxFlex = "widthOfTable" > {{ key | translate }} </div> < div class="separator" > ...

Safari's flexbox wraps the final column on the top row

When viewed in Safari and some other iOS based browsers, the last column of the first row wraps to the next line. Safari: https://i.sstatic.net/FhYyn.jpg Chrome / Others: https://i.sstatic.net/Vkvr0.jpg Code: .flexthis { display: -webkit-box; d ...

Why does a relatively positioned element always begin at the top corner of the window?

I am really struggling to understand the concept of relative versus absolute positioning, especially when dealing with parent or grandparent elements that have position values. Can someone please help me clarify these two scenarios: Case 1: grandparent ...

How to extract the value of an HTML text field by executing an SQL query in PHP

Sign In Page: Here is where users can enter their login credentials. Method used is PHP POST. <html> <head> <title> LOG IN </title> <style> body { text-align: center; } </style> </head> <body> <form ac ...

Maximizing the potential of Angular forms through native FormData

Currently, I am revisiting an older project that still uses traditional methods for form submission. The HTML includes a form element with defined method and action. My goal is to submit the form in the old-fashioned way using the action attribute to post ...

using sass to nest multiple classes

In an attempt to utilize nested classes with Sass, I am working on a styling code that displays a button on hover. Here is the structure of my SCSS: .item{ border-bottom: 1px dotted #ccc; text-indent: 50px; height: 81%; padding: 2px; text-transf ...

The swipe function of Hammer.js is unable to detect gestures on a rotated iframe

After creating a rotated iframe on the page using CSS transforms, I attempted to implement swipe events within the iframe. body.rotate iframe { transform: rotate(90deg); transform-origin: top right; position: absolute; t ...