I am trying to use create a separator between my links by creating a border on the right side of each of them. Then on the last one, remove it. I have the following html and css but what I’m finding is that each “a” tag matches the last-child selector. I’m not clear why and what the proper way would be to do this.
<ul class="nav">
<li><a href="#">link1</a></li>
<li><a href="#">link2</a></li>
<li><a href="#">link3</a></li>
<li><a href="#">link4</a></li>
</ul>
.nav a { border-right:solid 1px #000;}
.nav a:last-child { border-right-width:0px;}
That’s because each
ais the last-child of its parentli. You’d want something like.nav li:last-child ainstead.