A line-break can be added in HTML, using only CSS, by employing the pseudo-class ::after
or ::before
. In the stylesheet, we use these pseudo-classes, with the HTML class or id, before or after the place where we want to insert a line-break.
In myClass::after
:
content
property to "\a"
(the new-line character).white-space
property to pre
. This way, the browser will read every white-space, in myClass
, as a white-space.1. HTML without a line-break:
2. Using ::after
to insert a line-break:
3. Using ::before
to insert a line-break:
RELATED TAGS
View all Courses