How to add spaces in HTML? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

How to add spaces in HTML?

Let’s say I want to show something is a paragraph and I will write: Hello. But it will put out: Hello. How can I make the spaces count?

9th Mar 2018, 4:33 PM
Jax
Jax - avatar
10 Answers
+ 9
& nbsp; = single non-breaking space & ensp; = double space & emsp; = quad space <pre></pre> = HTML tags for preformatted text. Should keep your spacing. padding-left: = CSS means of adding padding, giving you space/indentation.
9th Mar 2018, 4:45 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 20
&nbsp;
9th Mar 2018, 4:41 PM
Salif Mehmed 🇹🇷🇧🇬
Salif Mehmed  🇹🇷🇧🇬 - avatar
+ 7
thanks for information @Jakob Marley
9th Mar 2018, 4:59 PM
Bug Slayer
+ 4
Thanks guys! 😃
9th Mar 2018, 4:41 PM
Jax
Jax - avatar
+ 3
or use the <pre> tag,it respects spaces
9th Mar 2018, 4:44 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 3
Thanks so much everyone!
9th Mar 2018, 5:08 PM
Jax
Jax - avatar
+ 2
when writing html,spaces more than 2 are ignored.The solutions to this? moving the elements itself with css.
9th Mar 2018, 4:37 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 2
@Nia Alavandi I’m sorry, but I don’t know ruby. You can try posting your own question though. You’re bound to get some help. @Brains I have not completed the CSS course. Will it teach me how in it?
9th Mar 2018, 4:40 PM
Jax
Jax - avatar
+ 2
You can use the entity &nbsp: <p> &nbsp; Hello </p> If you only want one word to be centered you can play with CSS and the classes. For example, you could use a span tag in this case and adjust the left margin as you like (recommended): <p> <span class = "has-margin-left"> Hello </span> </p> CSS: .has-margin-left { margin-left: 15px; }
9th Mar 2018, 4:40 PM
Mickel
Mickel - avatar
- 1
hi Jax im new can u plz help with the ruby tutorial i just started and my name is nia.
9th Mar 2018, 4:34 PM
Nia Alavandi
Nia Alavandi - avatar