HTML Tutorial
HTML XHTML
HTML Media
HTML Advanced
In HTML, spaces can be typed using the space character (ASCII code 32) or by using the
entity.
Here's an example of how to use the space character in HTML:
<p>This is a paragraph with multiple spaces.</p>
In this example, multiple spaces are typed between the words in the paragraph. However, when the web page is rendered, the spaces will be collapsed into a single space.
entity. The
entity represents a non-breaking space, which is a space that cannot be broken by line breaks or word wraps.Here's an example of how to use the
entity in HTML:
<p>This is a paragraph with multiple spaces.</p>
In this example, the
entity is used to type spaces between the words in the paragraph. When the web page is rendered, the spaces will be displayed as non-breaking spaces, and the browser will not collapse them into a single space.
By using the space character or the
entity, you can type spaces in HTML and control how they are displayed in the web page.
HTML space character:
<p>This is a space character.</p>
Adding spaces in HTML:
<p>Add spaces in HTML.</p>
HTML non-breaking space:
) prevents browsers from collapsing consecutive spaces into a single space.<p>This is a non-breaking space.</p>
Inserting spaces in HTML code:
<div> <p>Inserting spaces for readability.</p> </div>
Using in HTML:
<p>This is a sentence with multiple spaces.</p>
HTML whitespace handling:
<pre> Whitespace Handling </pre>
Creating indentation in HTML:
<ul> <li>Item 1</li> <li>Item 2</li> </ul>
HTML space vs. :
both add space, but
prevents collapsing of consecutive spaces.<p>Space vs. Non-Breaking Space.</p>
HTML multiple spaces:
<p>Multiple Spaces in HTML.</p>
HTML text spacing:
letter-spacing
or word-spacing
.p { letter-spacing: 2px; }
Whitespace preservation in HTML:
<pre> Whitespace Preservation </pre>
HTML preformatted text:
<pre>
element preserves whitespace, displaying text exactly as it appears in the code.<pre> Preformatted Text </pre>
HTML code formatting for spaces:
<div> <p>Code formatting with spaces.</p> </div>
HTML space entities:
or  
can be used to represent space characters.<p>Space entities: and  </p>
Spacing elements in HTML:
margin
and padding
are used to create spacing between HTML elements.div { margin-top: 10px; }
HTML space character alternatives:
<p>Alternative to space.</p>
HTML space and line breaks:
<p>Space and<br>Line Breaks</p>
HTML space character in URLs:
%20
to ensure proper interpretation by browsers.<a href="page%20url.html">Link with Space in URL</a>
HTML text alignment and spacing:
text-align
and line-height
can be used to control text alignment and spacing.p { text-align: center; line-height: 1.5; }
HTML pre tag for preserving spaces:
<pre>
tag is used to preserve spaces and display text in a fixed-width font.<pre> Preserving Spaces </pre>