Newline character sequence in CSS 'content' property? [duplicate] Ask Question

Newline character sequence in CSS 'content' property? [duplicate] Ask Question

Is it possible to use newline character in CSS content property to force a line break? Something like:

figcaption:before
{
    content: 'Figure \n' + attr(title);
}

ベストアンサー1

figcaption:before
{
    content: 'Figure \a' attr(title);
    white-space: pre;
}

Note that in the content attribute value, concatenation is expressed just by whitespace, not by a “+” sign. The escape notation \a in a CSS string literal indicates a linebreak character.

おすすめ記事