How do you to put spaces between text in html? For example,
a b c
What do you put to have space between b and c?>
There are several ways.
Pre Tag
One is to use the tag, which will render content with the whitespace intact.
Space Entities
Another is to add space entities, like
(non-breaking space). Keep in mind with this approach, there are several space entities, and this particular entity does not word-wrap, which may not be the behavior you wanted.
renders a normal space, which the browser should not collapse, and which will word-break as expected.
Here is a list of different Unicode spaces you can use.
CSS
Also, you usually should not use HTML entities to create space between text which is not part of one uniform sentence. This is because in this case, the better solution is to use margin
or padding
to separate the two, and keep each in its own element.
As another answer mentions, CSS letter-spacing
is also an option if the spacing is consistent but larger than normal.
Here's an example of all these approaches (the CSS is not important here):
th, td {
border: 1px solid black;
padding: 3px;
}
th {
background-color: darkgrey;
color: white;
}
table {
border-collapse: collapse;
}
body {
font-family: sans-serif;
}
HTML Spacing
Method
Result
Normal a b c
Pre Tag a b c
Margin Left a bc
Non-breaking Space a b c
Em Space a b c
Letter-Spacing a bc