US Trends

how to give space in html

Here’s a practical, SEO‑friendly “Quick Scoop” on how to give space in HTML , with simple examples and modern best practices.

How to Give Space in HTML

Spacing in HTML is mostly controlled in two ways:

  • Within text (between words/letters/lines).
  • Around elements (between boxes, sections, paragraphs).

Below are the main techniques you’ll actually use in real projects today.

1. Extra space in text (inline spacing)

a) Non‑breaking space:  

HTML collapses normal spaces: typing many spaces in a row will usually show as just one. To force visible spaces, use the HTML entity   (non‑breaking space). It also prevents line breaks at that position.

html

<p>This is normal text.</p>
<p>This&nbsp;has&nbsp;extra&nbsp;spaces.</p>
<p>Label:&nbsp;&nbsp;&nbsp;Value</p>

When to use:

  • A small “manual” gap between words or symbols.
  • Keeping “Rs.” and a price together on one line (e.g., Rs.&nbsp;500).

When not to overuse:

  • Don’t spam dozens of &nbsp; to push content around; that’s what CSS is for.

b) En and em spaces: &ensp; and &emsp;

These are wider types of spaces often used in typography.

html

<p>Text&ensp;with&ensp;en&nbsp;spaces.</p>
<p>Text&emsp;with&emsp;em&nbsp;spaces.</p>
  • &ensp; ≈ medium space.
  • &emsp; ≈ wide space.

They’re nice for subtle alignment or spacing in headings, labels, or navigation where you don’t want to fiddle with CSS for tiny details.

c) Preserve spacing exactly: <pre>

If you want HTML to keep every space, tab, and line break exactly as written, wrap the text in a <pre> tag.

html

<pre>
Line 1     has     many spaces
Line 2   is    also   spaced
</pre>

Use cases:

  • Code blocks.
  • ASCII diagrams.
  • Poems or formatted text where layout matters.

Avoid using <pre> for normal paragraphs; it’s better for special cases.

2. Line breaks and basic vertical spacing

a) Line break: <br>

The <br> tag forces content to continue on the next line and adds a small vertical spacing.

html

<p>
Line one.<br>
Line two.<br>
Line three.
</p>

Good uses:

  • Addresses.
  • Short, lyric‑style lines.
  • Where a single extra line break is truly part of the content.

Avoid using <br><br><br> as your main layout tool; use CSS margin/padding instead.

b) Paragraphs: <p>

Every <p> is a block element that comes with default space before and after it in browsers.

html

<p>This is the first paragraph.</p>
<p>This is the second paragraph with automatic space above it.</p>

This is one of the most natural ways to separate blocks of text. If you want more (or less) space between paragraphs, you control it with CSS:

html

p {
  margin-bottom: 1.5rem; /* More space after each paragraph */
}

3. Proper spacing between elements (CSS way)

For layout, modern HTML uses CSS. This is the clean, maintainable way.

a) Margin: space outside an element

Use margin to create space around an element, separating it from others.

html

<style>
.card {
  margin: 20px;        /* Space around the card */
  padding: 15px;       /* Inner space */
  border: 1px solid #ccc;
}
</style>

<div class="card">
  Content inside the card.
</div>

<div class="card">
  Another card with space around it.
</div>

Key ideas:

  • margin-top, margin-right, margin-bottom, margin-left to control each side.
  • margin: 20px 40px; (top/bottom 20px, left/right 40px).

Use margin when you want elements to be separated from each other.

b) Padding: space inside an element

Padding is the space between an element’s border (or background) and its content.

html

<style>
.box {
  padding: 20px;         /* Inner spacing */
  background: #f5f5f5;
}
</style>

<div class="box">
  Text is not touching the border because of padding.
</div>

Use padding when:

  • Buttons look cramped.
  • Cards or containers need breathable content.
  • You want the background “box” to have internal spacing.

c) Line height: vertical space between lines of text

html

<style>
.text {
  line-height: 1.8;    /* 1.8x the font size */
}
</style>

<p class="text">
  This paragraph has more vertical space between lines, which improves readability.
</p>

Use line-height to:

  • Make paragraphs easier to read.
  • Avoid text looking “squashed”.

d) Word and letter spacing

If you want more space between letters or words:

html

<style>
.loose-letters {
  letter-spacing: 2px;
}

.loose-words {
  word-spacing: 10px;
}
</style>

<p class="loose-letters">Spread letters</p>
<p class="loose-words">More space between these words</p>

These are great for:

  • Logos or big headings.
  • Stylized titles.
  • Fine‑tuning typography without using &nbsp; everywhere.

4. Spacing patterns in real layouts

Here are some quick mini‑patterns you might actually use in a page.

Example 1: Section spacing

html

<style>
.section {
  margin: 40px 0;    /* Space above and below each section */
}
</style>

<section class="section">
  <h2>About Us</h2>
  <p>Some description text here.</p>
</section>

<section class="section">
  <h2>Services</h2>
  <p>Details about services.</p>
</section>

Example 2: Spaced form fields

html

<style>
.form-field {
  margin-bottom: 16px;   /* Space between fields */
}
</style>

<form>
  <div class="form-field">
    <label>Name:</label><br>
    <input type="text">
  </div>

  <div class="form-field">
    <label>Email:</label><br>
    <input type="email">
  </div>
</form>

Example 3: Simple inline spacing without CSS

If you absolutely can’t touch CSS (e.g., some email templates), you can use &nbsp; carefully:

html

<p>
  Home&nbsp;&nbsp;|&nbsp;&nbsp;About&nbsp;&nbsp;|&nbsp;&nbsp;Contact
</p>

5. What not to do for spacing

Some habits used in very old HTML or in quick‑and‑dirty code are now considered bad practice:

  • Using empty <p> tags like <p>&nbsp;</p> just for space.
  • Adding lots of <br> solely to push things down.
  • Inserting empty <div> or <span> elements as spacers.
  • Relying on many &nbsp; to position layout.

All of those make code harder to maintain and break easily on different screen sizes. CSS margin/padding is the modern, responsive approach.

Mini FAQ (today’s “forum style”)

Q: What’s the fastest way to add a visible space in HTML text?
A: Use &nbsp; between words when you need more than one space to show.

Q: How do I add space between two HTML elements, not text?
A: Add margin in CSS to one or both elements (e.g., .box { margin- bottom: 20px; }).

Q: How do I make lines of a paragraph less cramped?
A: Increase line-height (for example line-height: 1.6;).

Q: Should I use<br> or CSS for vertical spacing?
A: Use <br> for content‑based line breaks (like addresses); use CSS margins for layout spacing.

SEO mini‑note (for your post)

If you’re writing a blog or forum post targeting the keyword “how to give space in HTML” , try to:

  • Include the phrase naturally in:
    • The main heading (<h1>),
    • At least one <h2>,
    • The meta description (“Learn how to give space in HTML using , line breaks, and CSS margin/padding with clear examples.”).
  • Keep paragraphs short and use bullet lists like above for readability.
  • Add code snippets so developers can copy‑paste quickly.

Tiny HTML table example (methods at a glance)

html

<table border="1" cellpadding="6">
  <tr>
    <th>Goal</th>
    <th>Best method</th>
    <th>Example</th>
  </tr>
  <tr>
    <td>Extra space between two words</td>
    <td>&nbsp; or &ensp;/&emsp;</td>
    <td><code>Word1&nbsp;&nbsp;Word2</code></td>
  </tr>
  <tr>
    <td>New line / line break</td>
    <td>&lt;br&gt;</td>
    <td><code>First line&lt;br&gt;Second line</code></td>
  </tr>
  <tr>
    <td>Space between paragraphs/blocks</td>
    <td>CSS margin</td>
    <td><code>p { margin-bottom: 16px; }</code></td>
  </tr>
  <tr>
    <td>Inner space in a box</td>
    <td>CSS padding</td>
    <td><code>.box { padding: 20px; }</code></td>
  </tr>
  <tr>
    <td>More space between lines</td>
    <td>CSS line-height</td>
    <td><code>p { line-height: 1.7; }</code></td>
  </tr>
  <tr>
    <td>More space between letters/words</td>
    <td>CSS letter-spacing / word-spacing</td>
    <td><code>.title { letter-spacing: 3px; }</code></td>
  </tr>
</table>

TL;DR:
Use &nbsp; (and friends) for small inline gaps, <br> for explicit line breaks, and CSS margin/padding/line-height for all serious spacing between elements and lines.