Given an HTML attribute, location-id
, whose value is three unicode characters:
.loc::before { content: attr(location-id) }
<span class="loc" location-id="▶ ▶"></span>
the three unicode characters are displayed as intended: two ▶ characters separated by a space.
How, if it is possible, do I instead put a newline between the two arrows, so one displays above the other?
Neither of these work:
<span class="loc" location-id="▶
▶"></span>
<span class="loc" location-id="▶
▶"></span>
I get, on one line, a space between two arrows.
2
Answers
You don’t get explicit line breaks in pseudo element content (e.g. you can’t slip a newline into an attribute and make that work), but you can just explicitly mark your content as a block (or inline-block, table-cell, whatever actually makes sense for your content) and then give it a width that causes text to wrap to the next line, just like in "regular" CSS.
Also, HTML can do unicode just fine: no need for codepoint entities, if you need ▶, just write ▶, that will work perfectly fine:
In HTML by default line break (or a sequence of breaks and/or spaces) is being displayed as a single
space
symbol.But you can change that using
white-space: pre
: