Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

converting white space into line break

Tags:

css

Is it possible to add a line break on each white space using CSS?

For example, if I have string "Format It" I would like to display it like

Format
It

using CSS.

like image 494
user3733648 Avatar asked Jul 01 '14 12:07

user3733648


People also ask

Is line break a whitespace?

A white space can be a sequence of spaces (entered using the space or the tab keys) or a line break (entered using the carriage return key (or the Enter key), or <br/> ).

How do you create a line break?

Press ALT+ENTER to insert the line break.

How do you put a line break in space in HTML?

HTML Break (<br>) Tag If you want to insert a line break, use the HTML break tag, written as <br>. You don't need a closing tag here — just writing <br> adds a line break.


1 Answers

You can use the word-spacing property. It defines the space between the words. If you set it to the size of the container, it will force a line break...

Since it doesn't accept percentual values, you can use relative values like vw.

div {
    word-spacing: 100vw;
}

http://jsfiddle.net/ApL3h/

like image 160
LcSalazar Avatar answered Sep 20 '22 04:09

LcSalazar