0

I'm building an list in HTML with items that stands next to each other (inline). All items have to be separated with a bullet (&bull) with some padding left and right. My question: how do I target te &bull to add some padding?

<ul>
    <li><a href="#">Disclaimer</a>&bull;</li>
    <li><a href="#">Sitemap</a>&bull;</li>
    <li><a href="#">Other</a></li>
</ul>

The CSS code I tried is:

ul li a:after{
    padding: 0 10px 0 10px;
}
8
  • 1
    Why not add padding directly to the a tag? Commented Sep 13, 2014 at 6:37
  • Something like this? fiddle Commented Sep 13, 2014 at 6:42
  • 1
    If you're going to use an :after pseudo-element, put the symbol in the pseudo-element instead of in the markup. Commented Sep 13, 2014 at 6:44
  • @harry if I give padding left and right to the a tag, the first element will have a padding-left and be out of grid. Commented Sep 13, 2014 at 6:47
  • @BoltClock:is my answer correct as you intended ? Commented Sep 13, 2014 at 6:49

2 Answers 2

2

you can give margin to anchor tag

or you can try this

<ul>
    <li><a href="#">Disclaimer</a><span>&bull;</span></li>
    <li><a href="#">Sitemap</a><span>&bull;</span></li>
    <li><a href="#">Other</a></li>
</ul>

and giv padding to span

Sign up to request clarification or add additional context in comments.

4 Comments

Looks like this is the best way to do this. Thanks for the clear solution.
@user2381011:try my answer..!!
What does "you can give a margin to a tag" mean? The problem is, there is no tag around the &bull;.
sorry that a tag is anchor tag
2

try this

DEMO FIDDLE

MARKUP

<ul>
    <li><a href="#">Disclaimer</a>
    </li>
    <li><a href="#">Sitemap</a>
    </li>
    <li><a href="#">Other</a>
    </li>
</ul>

CSS

ul li {
    display:inline-block;
}
ul li a:after {
    content:"\2022";
    padding: 0 10px 0 10px;
} 

1 Comment

I tried your answer as well and it almost fits as a solution. Only the last element don't needs a bullet. I tried this as alternative but it doesn't work a:not(:last-child):after

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.