Home > Web Front-end > CSS Tutorial > How to Add Line Breaks to ::after or ::before Pseudo-Element Content in CSS?

How to Add Line Breaks to ::after or ::before Pseudo-Element Content in CSS?

Susan Sarandon
Release: 2024-11-15 05:43:02
Original
527 people have browsed it

How to Add Line Breaks to ::after or ::before Pseudo-Element Content in CSS?

Adding Line Breaks to ::after or ::before Pseudo-Element Content

Question:

How do you add multiple lines to the content property of a ::after or ::before pseudo-element when access to the markup is limited to CSS?

Answer:

The 'content' property allows line breaks to be inserted using the "A" escape sequence. However, to prevent line wrapping, set the 'white-space' property to 'pre' or 'pre-wrap'.

Example:

#headerAgentInfoDetailsPhone:after {
  content: "Office: XXXXX \A Mobile: YYYYY ";
  white-space: pre;
}
Copy after login

For more robust escaping, use "

The above is the detailed content of How to Add Line Breaks to ::after or ::before Pseudo-Element Content in CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template