1

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?

1
  • 1
    Make you <div> wide enough then your text will not wrap. Maybe we can offer better help if you show us the style of class="text". Commented May 24, 2017 at 14:19

2 Answers 2

3

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

JSFiddle

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I think you misunderstood the OPs issue. He complains about his to words being separated by line wrapping instead of being displayed in one line separated by a space.
2

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>

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.