Best way to manage whitespace between inline list items

Several options here, first I’ll give you my normal practice when creating inline lists: <ul id=”navigation”> <li><a href=”#” title=””>Home</a></li> <li><a href=”#” title=””>Home</a></li> <li><a href=”#” title=””>Home</a></li> </ul> Then the CSS to make it function as you intend: #navigation li { display: inline; list-style: none; } #navigation li a, #navigation li a:link, #navigation li a:visited { display: … Read more

CSS: Last element on line

Interesting question! Here’s what I consider a “low-tech” solution with jQuery that does the trick: $(function() { var lastElement = false; $(“ul > li”).each(function() { if (lastElement && lastElement.offset().top != $(this).offset().top) { lastElement.addClass(“nobullet”); } lastElement = $(this); }).last().addClass(“nobullet”); });​ The algorithm is not hard to follow, but here’s the idea: iterate over the elements, taking … Read more

How do I render side-by-side?

li { display: inline; } EDIT: I now realize why I felt strange answering with display: inline: because I usually use float: left myself instead, which is anthony-arnold’s answer (so to him goes my upvote!). Anyway, while either method will cause your lis to display in one line, inline elements and floated elements do behave … Read more

Number nested ordered lists in HTML

Here’s an example which works in all browsers. The pure CSS approach works in the real browsers (i.e. everything but IE6/7) and the jQuery code is to cover the unsupported. It’s in flavor of an SSCCE, you can just copy’n’paste’n’run it without changes. <!doctype html> <html lang=”en”> <head> <title>SO question 2729927</title> <script src=”http://code.jquery.com/jquery-latest.min.js”></script> <script> $(document).ready(function() … Read more

Text Separators for LI Elements

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: “https://stackoverflow.com/”; } #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: “https://stackoverflow.com/”; … Read more

Should the CSS property list-style be applied to / or ?

According to the W3C CSS2 reference, which can be found here, Another solution would be to specify ‘list-style’ information only on the list type elements: ol.alpha { list-style-type: lower-alpha } ul { list-style-type: disc } Inheritance will transfer the ‘list-style’ values from OL and UL elements to LI elements. This is the recommended way to … Read more

Should the CSS property list-style be applied to / or ?

According to the W3C CSS2 reference, which can be found here, Another solution would be to specify ‘list-style’ information only on the list type elements: ol.alpha { list-style-type: lower-alpha } ul { list-style-type: disc } Inheritance will transfer the ‘list-style’ values from OL and UL elements to LI elements. This is the recommended way to … Read more

tech