How to remove last border from navigation bar?

Hello, im wondering how do i remove this last border on the right from the nagivation bar? I tried :last-child but it didnt work, it removed borders for other link’s too.

Here’s my html:

<!doctype html>
<html>
<head>
<title>Index</title>
<meta charset="utf-8">
<meta name="description" content="Testing site">
<meta name="keywords" content="HTML, CSS, JavaScript, PHP">
<meta name="author" content="Ismar">
<meta http-equiv="content-type" content="text/html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="Index.css">
</head>
<body>
<ul id="navbar">
    <li id="list"><a id="link" href="#">Link</a></li>
    <li id="list"><a id="link" href="#">Link</a></li>
    <li id="list"><a id="link" href="#">Link</a></li>
    <li id="list"><a id="link" href="#">Link</a></li>
    <li id="list"><a id="link" href="#">Link</a></li>
</ul>
<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.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>

CSS:

body 
    {
    margin: 0; 
max-width: 100%;
  overflow-x: hidden;
    }

#navbar {background-color: antiquewhite;}
#navbar #list {display: inline; padding: 70px;}
#navbar #list #link {border-right: 1px solid; padding-right: 140px;}

Use :

#navbar li:nth-child(5){
border-right:0;
}

But make sure to add this rule below all of your rules so that it woul override any existing rules with the same declaration

1 Like

You can use :nth-child(5) or :last-of-type

And you can’t have same id for more than one tag
The id selector uses the id attribute of an HTML element to select a specific element.
The id of an element should be unique within a page, so the id selector is used to select one unique element.
Instead of id, use class

<ul id="navbar">
    <li class="list"><a class="link" href="#">Link</a></li>
    <li class="list"><a class="link" href="#">Link</a></li>
    <li class="list"><a class="link" href="#">Link</a></li>
    <li class="list"><a class="link" href="#">Link</a></li>
...
</ul>
1 Like