i'm looking for a solution to replace a line break <br>
with a character, let's say a comma.
i'm having a website that displays credits to images. in landscape mode credits are displayed like this:
title
artist
year
in portrait mode it should be displayed like this:
title, artist, year
so far i found this solution, works in safari, safari for ios and chrome (haven't tested chrome on android but i guess it should work too):
first set an empty content to remove the line break
br {content: '';}
then set the string you want the line break to be replaced with
br:after {content: ', ';)
if you need the line break to work normally again put
br {content:none;}
works great actually but is it the right way to do this? how would you replace a line break with a character in css? i'm looking for a solution in which the end user of the cms doesn't have to add too much html code when entering the credits.
contentshould only work with the:beforeand:afterpseudo-classesbris an empty/void element, so it can't contain any content.