From the journal

Add content using CSS.

I recently faced a problem in a website, where I have to add a separtor after each li ends. And the speartor should not come for last li I learned this can be achieved through CSS. Let us say out…

Explore this page ↓
Share

I recently faced a problem in a website, where I have to add a separtor after each li ends. And the speartor should not come for last li I learned this can be achieved through CSS.

Let us say out Menu structucture is like this.

<div class="menu">
<ul>
<li>Home</li>
<li>About Us</li>
<li>Services</li>
<li>Contact Us</li>
</ul>
</div>

My css for this menu is

.menu li:after{content: “|”;}

.menu li:last-child:after{content: “”;}

As you can see the “after” and content did the job. For finding the last li in the list “last-child” is used.

Hope this will help you some where.

Keep reading