0

how can I get rid of the spacing between the navigation menu links? I want them to look as if they are in one cell and instead use borders between them!

   

body { background-color:white;
}
ul { list-style-type:none; text-align:center; margin:0auto; text-align:center; padding:0px; display:block; overflow:hidden;}   
 


li a {display:block;text-decoration:none; text-transform:uppercase; padding:8px; background-color: #dddddd;}

li {

  display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="prova.css">
</head>
<body>
<ul>
  <li><a href="#home">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li><a href="#about">About</a></li>
</ul>

</body>

</html>

2 Answers2

1

Using display: inline-block, simply removing the line breaks is enough to remove the space, since the <li>s are behaving like text.

   

body { background-color:white;
}
ul { list-style-type:none; text-align:center; margin:0auto; text-align:center; padding:0px; display:block; overflow:hidden;}   
 


li a {display:block;text-decoration:none; text-transform:uppercase; padding:8px; background-color: #dddddd;}

li {

  display: inline-block;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="prova.css">
</head>
<body>
<ul>
  <li><a href="#home">Home</a></li><li><a href="#news">News</a></li><li><a href="#contact">Contact</a></li><li><a href="#about">About</a></li>
</ul>

</body>

</html>
Toby
  • 10,294
  • 6
  • 36
  • 62
0

so try this

li {
    margin-left: -4px;
    display: inline-block;
}
demopix
  • 171
  • 5