I'd like to add a forward slashes ('/') between my li elements, but I'm not sure of the best way to do that semantically. Right now, I'm simply including the forward slash in the li tag and adding spacing with non-breaking spaces, like so:
<ul id="footer_menu"> <li>Customer Support /</li> <li>Shipping Info /</li> <li>Size Charts /</li> <li>Privacy Policy /</li> <li>Contact</li> </ul>
What do you think? Thanks.
To create space between list bullets and text in HTML, use CSS padding property. Left padding padding-left is to be added to <ul> tag list item i.e. <li> tag. Through this, padding gets added, which will create space between list bullets and text in HTML.
Yes it is possible. I created an example pen for you. Place your image files instead of the span tags.
You can use pseudo-elements to include text after an element and you can use CSS3 selectors to remove the trailing slash from the last element.
#footer_menu li:after { content: "/"; } #footer_menu li:last-child:after { content: ""; }
EDIT:
The whole thing can be done in one line with better CSS3.
#footer_menu li:nth-child(n+2):before { content: "/"; }
EDIT: EDIT:
It's even easier than that.
#footer_menu li + li:before { content: "/"; }
This is my solution for LI element separated by | (pipe) :
li + li:before { content: " | "; }
The adjacency combinator (a plus sign, +) comes in very handy in this case. It allows you to style an element if it has been directly preceded by another specified element. Since the first li is not preceded by another li, it won't have the content prepended to it. This is much less typing than:
li:before { content: " | "; } li:first-child:before { content: ""; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With