Here are two different methods to tackle this issue: one using pure CSS and the other utilizing jQuery. These solutions will allow for any symbol or image to be used as a separator.
Note: Creating and finding solutions for questions like these can be quite challenging, so I apologize if this has been addressed before.
I am dealing with a block of text that is multi-lined and justified, containing random (but not entirely) text hyperlink elements (such as tags or categories). These elements are separated by "|" symbols with spaces around them. This setup resembles a tag cloud but with fixed font-weight, size, and formatting. The problem arises when a separator is placed at the beginning or end of a line, which looks unattractive due to the nowrap setting on the link elements. I am looking for a solution to remove separators from the start and end of lines.
To better illustrate, let me provide an example:
C++ | PHP | CSS | ASP |
JavaScript | jQuery
| HTML 5 | StackOverflow
The layout above demonstrates the issue. Each line should have content aligned to both sides without separators trailing off the ends. My goal is to achieve a structure similar to this:
C++ | PHP | CSS | ASP
JavaScript | jQuery
HTML 5 | StackOverflow
Having a fixed number of elements in each line or enforcing a fixed width is not feasible in this scenario.
The only workaround I have thought of involves using monospace fonts and programmatically counting symbols to print line-by-line with server-side scripting. However, this approach comes with the downside of having to use monospace fonts. I am seeking a more elegant solution, such as implementing pure HTML/CSS (ideal) or formatting with JavaScript/jQuery after output.
Thank you for your assistance!
EDIT: In response to a comment below, the markup can be flexible and structured according to preference, something like:
<div><a href="#">tag 1</a> | <a href="#">tag 2</a> | <a href="#">tag 3</a></div>