Navigation bar problem

I am trying to create a navigation bar.

I used display: flex for nav-div class with justify-content: space-between.

This keep happening. There is a huge gap in the right.


<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Navigation Bar</title>
        * {
            box-sizing: border-box;
            text-decoration: none;

        .nav-bar {
            background-color: aquamarine;
            font-family: Verdana, Geneva, Tahoma, sans-serif;
            padding-left: 15px;
            padding-right: 15px;
            border: 2px solid black;

        .nav-div {
            display: flex;
            justify-content: space-between;

        .nav-logo a {
            font-size: 2.5rem;
            font-weight: 800;
            /* color: white; */

        li {
            list-style: none;
            display: inline-block;

        li a {
            font-size: 18px;
            font-weight: bold;
            margin: 0 10px;

        button {
            background-color: rgb(251, 145, 59);
            border: none;
            border-radius: 10px;
            margin: 0 10px;
            padding: 5px 10px;
            width: 90px;

        button a {
            font-size: 15px;
            font-weight: bold;
    <nav class="nav-bar">
        <div class="nav-div">
          <div class="nav-logo"><a href="#">DP</a></div>
            <li><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Gallery</a></li>
            <li><a href="#">Team</a></li>
            <li><a href="#">Sponser</a></li>
            <li><a href="#">Contact</a></li>
            <button><a href="#">Register<a></button>

This is the Result:

Try the following:

 .nav-div {
            display: flex;
            justify-content: flex-end;
           margin-left: 25px;

        .nav-logo a {
            font-size: 2.5rem;
            font-weight: 800;
            position: absolute;
            left: 25px;
            top: 15px;

You should get something like this:

I suppose this is what you want to create.

You didn’t close the a element correctly.

<a href="#">Register<a>

Should be

<a href="#">Register</a>
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.