Optional line-breaking HTML entity that is always invisible -
i want optional line-breaking character invisible works word-wrap: break-word;
css style.
here specifics. goal break apart long links in reasonable places. these characters place start: -
, .
, _
, /
, \
. not rails-specific question, wanted share code i'm using now:
module applicationhelper def with_optional_line_breaks(text) text.gsub(%r{([-._/\\])}, '\1­') end end
here's problem code above: when ­
takes effect (in table with: word-wrap: break-word;
), ­
gets displayed -
. don't want see -
; want line break without character shown.
​
html entity unicode character called zero-width space (zwsp).
"in html pages, space can used potential line-break in long words alternative
<wbr>
tag."- zero-width space - wikipedia
the <wbr>
tag works, mentioned aaron's answer. think prefer html entity on tag because entity seems simpler: unicode handles it, not web browser.
Comments
Post a Comment