Insert a line break before an element using CSS only
To achieve this you need two things:
- use the
\A
escape sequence character incontent
part of::before
selector and - add
white-space: pre;
style to the same selector.
This will force new line before that page element.
Same goes for ::before
selector of course.
So:
.post-date::before { content: "("; color: silver }
becomes:
.post-date::before { content: "\A("; color: silver; white-space: pre-line }
And that’s all.
Sources:
- “How to insert line break before an element using CSS?” article at GeeksforGeeks and
- an answer to “How to insert a line break before an element using CSS?” question at Stack Overflow.