Reputation: 33
I am trying to place some text on my html website and it has a space in it.
<div class="text">
text text
</div>
When I open the website, it doesn`t display it as a space, but it goes to a new line between the 2 words. How do I type out a space?
Upvotes: 1
Views: 131
Reputation: 3446
You could use the <br>
element.
top stuff
<div class="text">
<br>
text text
<br>
<br>
more text
<div>
You can read more about <br>
here: https://developer.mozilla.org/en/docs/Web/HTML/Element/br
Note that you need two br's to seporate two lines of text, and one for the equivalent of a carriage return. None, puts the second line on top of the first.
Upvotes: 3
Reputation: 1915
If you want to preserve the space in the div
you can use white-space: pre
:
.text{ white-space: pre; }
<div class="text">
text text
</div>
Upvotes: 2