What is the best way to add two hyperlinks within a single tab of a Bootstrap navigation menu?

I attempted to place two links in one tab, but I was unsuccessful. Here is my navbar code:

<!DOCTYPE html>
<html lang="eng">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f2d20203b3c3b3d3e3f0f7a617d617c">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Latest compiled JavaScript -->
    <script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="34565b5b4047404647554474011a061a07">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>

    <title>{% block title %} welcome to music stories{% endblock %}</title>

    </style>
</head>
<body>

    {% if user.is_authenticated %}
        <div class='alert alert-success alert-dismissible fade show'>
            <button type= 'btn' class="btn-close" data-bs-dismiss='alert'></button>
            <p>{{user.username}}, welcome to music stories world</p>
        </div>
    {% else %}
        <div class="alert alert-danger alert-dismissible fade show">
            <button type="btn" class="btn-close" data-bs-dismiss='alert'></button>
            <a href="{% url 'users:login' %}" class="alert-link">Log In</a>
        </div>
    {% endif %}

    <a href="pages:home">Home</a>
    <nav class="navbar text-dark bg-warning container-fluid">
        <ul class="nav nav-tabs">
            {% if user.is_authenticated %}
                <li class="nav-item">
                    <a  class='nav-link active' href="#">{{user.username}}</a><br>
                    <a class="nav-link" href=" {% url 'user:logout' ">Log Out</a>
                </li>
            {% else %}
                <li class="nav-item">
                    <a class='nav-link active' href="{% url 'login' %}"> Log In</a>
                    <a class="nav-link" href="{% url 'users:signup'%}">Sign Up</a>
                </li>
            {% endif %}
            `<li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-bs-toggle='dropdown' href="tags">tags</a>
                <ul class="dropdown-menu">
                    <li><a class="nav-item" href="#">tag1</a></li>
                    <li><a class='nav-item' href="#">tag2</a></li>
                    <li><a class="nav-item" href="#">tag3</a></li>
                </ul>
            </li>
            <li class="nav-item"><a class="nav-link">communication</a></li>

            <li class="nav-item">
                <a class="nav-link" href="{% url 'pages:musiclist' %}">music list</a>
            </li>
            <li class="nav-item">
                <a class='nav-link' href="{% url 'pages:music_create' %}">add</a>
            </li>
        </ul>
    </nav>
    <div>
        {% block content %}{% endblock %}
    </div>
</body>
</html>

I wanted to combine both the username and logout links into one tab, or login and logout, how can I achieve this? Furthermore, I have a second unrelated question regarding overriding .container within the <nav>.

Answer №1

After reviewing your explanation, it seems that incorporating a DROPDOWN feature with options for username and logout would be beneficial (refer to this link).

Regarding overriding the container class, a more effective approach would involve creating a new class such as container-main in your css file to customize the styling and then applying it to your div element.

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

Problem with holding a dropdown button

Having trouble maintaining the position of this button within the floating button holder above my website content. How can I incorporate a drop-down menu while ensuring it stays within the same button holder? .btn-holder { backgr ...

Show a directional indicator on hover in the date selection tool

I am currently using a datepicker that looks like this: https://i.sstatic.net/XsrTO.png When I hover over it, three arrows appear to change days or show the calendar. However, I would like to remove these arrows. Here is the code snippet: link: functi ...

Changing the font color of the status bar in a PWA on Chrome Desktop: A step-by-step guide

We recently developed a Progressive Web App (PWA) for our website and are now looking to customize the status bar font color to white. While we have come across various resources on how to change the background color of the status bar in a desktop PWA on ...

When a PHP if statement is triggered by reading a text file, it activates a checked

I am working on a PHP project that involves an on-off button and a txt file. The goal is to have the button disabled (with 'unchecked' echoed) when the value in the txt file is true, and enabled (with 'checked' echoed) when the value is ...

What is the best way to transfer a table with multiple rows in a single column to an Excel spreadsheet while maintaining the headers on a horizontal plane

Currently, I am in the process of gathering data. The data is being sent to me in a word format and organized in a vertical columned table with different headers and alternating data. I am looking for a way to export this data from Word into an Excel spre ...

What is the process for displaying a hidden div using a button?

I'm running into a problem with my project. Here is the code I've been using to hide my div element : @keyframes hideAnimation { to { visibility: hidden; } } To trigger the animation and hide the div after 6 seconds, I have implemented ...

I would like to learn how to showcase a two-column array using PHP and HTML

In my current setup, I have a collection of icons that are displayed in groups of 4. This means that if there are 7 icons, the 4th icon on the first slide will be repeated as the 8th icon on the second slide. To resolve this issue, I am looking to iterate ...

The top margin in CSS relative positioning is not being displayed

My client has a specific requirement for the webpage to be positioned in the center of the screen. To achieve this, I have enclosed the entire webpage within a div element called "mainpage". Here is the CSS code: #mainpage { position:relative; wi ...

Customizing Text Placement in HTML Lists with CSS List-Style-Image

Is there a way to adjust the vertical positioning of the "Blahs" in the list so that they appear closer to the center of each list bullet in the image displayed on my HTML code below? Here is the snippet of code: <html> <style> li { margin-to ...

The utilization of bootstrap can lead to CSS interruptions

I am trying to create a navigation button that transforms from 3 horizontal lines to an X shape when clicked. var anchor = document.querySelectorAll('button'); [].forEach.call(anchor, function(anchor) { var open = false; an ...

Adjusting margins for different screen sizes in Bootstrap 5

Is it possible to adjust spacing (margin/padding) per breakpoint in Bootstrap 5? Using something like mb-sm-2 doesn't seem to have any effect... Am I doing something wrong? I've already looked at the official documentation, but I'm still c ...

What is the best method for selecting or isolating the code for a single animation created using JavaScript?

Currently, I am attempting to extract the CSS and JS code of an image reveal animation that is part of a static HTML page: https://i.stack.imgur.com/bnmaO.gif The challenge lies in the fact that the desired effect is one among many showcased image animat ...

Creating a customizable table in Angular with resizable columns that can retain their width and size preferences

I'm in the process of creating an Angular application that allows users to add or remove columns based on their preference and priority. My goal is to design a table with resizable column widths and save the adjusted column width in local storage so ...

Transforming JQuery code into pure Javascript: Attaching an event listener to dynamically generated elements

After exhausting all available resources on stack overflow, I am still unable to find a solution to my problem. I am currently trying to convert the JQuery function below into Vanilla JavaScript as part of my mission to make web pages free of JQuery. How ...

Using Android to Load HTML Content from a Database and Display in a WebView

I am currently facing an issue with loading HTML content from my sqlite database into a webview successfully. The HTML renders beautifully, however, the local file included in the HTML is not being loaded. I have placed it in the assets folder under this s ...

Tips for saving data from dynamically created input and select boxes

I have developed a webpage where users can add or delete rows by clicking on the addrow and delrow buttons. Everything is working fine so far. The issue I am facing now is that I need to store the values of dynamically generated fields using the post metho ...

Achieving an italicized appearance throughout an HTML document

I recently downloaded a sample page from the Mathjax website and acquired their package from Github to use it locally. In addition, I wanted to incorporate the computer modern font, so I unzipped the file containing ttf files into fonts/cmu. Here's ...

JavaScript functions do not work within the HTML code

I am currently working on my debut website and I'm facing an issue with the JavaScript file not functioning properly. Is there a chance you can help me troubleshoot this? I'm still in the learning stages of programming. This is the HTML content ...

JavaScript generated form fails to submit

I am currently facing an issue with submitting form data to a PHP file when it is generated using JavaScript. I am unsure of how to resolve this problem. The form submission works fine on a test .html file by itself, but not when it is generated by JavaScr ...

Displaying Title and Description Dynamically on Markers in Angular Google Maps

I am currently utilizing Angular-google-maps, and here is the HTML code snippet: <ui-gmap-google-map center='mapData.map.center' zoom='mapData.map.zoom' events="mapEvents"> <ui-gmap-markers models="mapData.map.markers ...