Skip to main content

HTML Paragraphs

Imagine opening a book where every page is one giant wall of words. No gaps, no breaks, nothing to rest your eyes on. You would probably close it after a few lines, right?

That is exactly why paragraphs exist. They chop your writing into small, friendly chunks so readers can breathe, follow your ideas, and keep going. In HTML, the tool for that job is the humble <p> tag, and it is one you will use in almost every page you ever build.


What You Will Learn​

By the end of this lesson, you will be able to:

  • Write a paragraph with the <p> tag
  • Understand why your extra spaces and blank lines seem to "disappear"
  • Style paragraphs with CSS so they are comfortable to read
  • Avoid the mistakes almost every beginner makes at least once
Good news

This is one of the easiest lessons in the whole tutorial. If you can type a sentence, you can write a paragraph.

Your First Paragraph​

A paragraph starts with <p> and ends with </p>. Everything you put between the two tags becomes one paragraph.

index.html
<p>Hello! This is my very first paragraph.</p>
<p>And this is my second one. See how it starts on a new line?</p>

Notice two things. Each paragraph starts on its own line, and the browser adds a little space between them. You did not have to ask for that. The browser does it for you.

Paragraphs Are "Block" Elements​

In HTML, a paragraph is a block-level element. Picture it as a rectangular box that stretches across the full width of its container. Because of that:

  • A paragraph always starts on a new line
  • It takes up the whole row, even if the text is short
  • The browser adds a margin above and below it (about 16px by default)

Think of paragraphs like boxes on a shelf. Each box gets its own row, and there is a small gap between rows.

Why Did My Spaces Disappear?​

Here is something that surprises almost everyone at first. Look at this code.

spaces.html
<p>
This paragraph has
lots of extra spaces


and blank lines.
</p>

You typed a bunch of spaces and blank lines, but the browser shows one tidy line. That is not a bug. It is called whitespace collapsing. The browser squishes any run of spaces, tabs, and line breaks into a single space.

Why does it work this way? So you can format your code however you like, with indentation and line wraps, without changing what visitors see.

Want to keep your spacing?

If you truly need spaces and line breaks preserved, you have two options. Use <br /> for a line break (next lesson), or use the <pre> tag for preformatted text.

Long Text? Break It Up​

Compare these two versions of the same text. Which one would you rather read?

<p>
HTML is the skeleton of every web page. It tells the browser what is a title,
what is a paragraph, and what is a link. CSS then adds colors and layout, and
JavaScript brings the page to life with interaction. Learning all three takes
time, but starting with HTML gives you a strong base for everything else.
</p>

A good rule of thumb: one paragraph, one idea. When your idea changes, start a new paragraph.

Styling Paragraphs with CSS​

The default look works, but a few small CSS tweaks can make your text much nicer to read.

styled-paragraph.html
<style>
p {
font-size: 1.1rem;
line-height: 1.7;
color: #334155;
max-width: 60ch;
}
</style>

<p>
Comfortable text is not an accident. A little extra line height and a limited
width make long paragraphs far easier on the eyes.
</p>

Here is what each property does:

CSS propertyWhat it doesFriendly tip
font-sizeChanges the text sizeKeep body text at 16px or larger
line-heightSets the space between linesTry 1.5 to 1.8 for easy reading
max-widthLimits how wide the text can getAround 60ch to 75ch works well
colorSets the text colorMake sure it contrasts with the background
text-alignAligns the textLeft-aligned is easiest for most readers
marginChanges the gap between paragraphsUse margin-bottom for even spacing

Mistakes Everyone Makes (and Easy Fixes)​

Do not worry if you have already done these. Every developer has.

Mistake 1: Using empty paragraphs for spacing​

<!-- Please don't -->
<p>First idea.</p>
<p></p>
<p></p>
<p>Second idea.</p>

Empty <p></p> tags add noise, not meaning. If you want more space, use CSS margin or padding instead.

Mistake 2: Putting one paragraph inside another​

<!-- This does not work the way you expect -->
<p>
Outer paragraph
<p>Inner paragraph</p>
</p>

Paragraphs cannot contain other paragraphs. The browser will quietly close the first one as soon as it sees the second, and your layout will not match what you wrote.

Mistake 3: Putting block elements inside a paragraph​

A <p> can hold text and inline elements like <strong>, <em>, <a>, and <code>. It should not hold headings, lists, or <div> elements.

<!-- Fine -->
<p>This is <strong>important</strong> and this is <em>stressed</em>.</p>

<!-- Not fine -->
<p>
<h2>A heading inside a paragraph</h2>
</p>

Mistake 4: Forgetting the closing tag​

Browsers are forgiving and will often guess where a paragraph ends. Still, always write </p>. It keeps your code clean and avoids strange surprises later.

Do not use paragraphs for everything

A paragraph is for a block of related sentences. If you need a title, use a heading. If you need a list of items, use a list element. Picking the right tag helps search engines and screen readers understand your page.

Paragraphs vs Line Breaks​

Beginners often ask, "Should I press Enter or start a new paragraph?" Here is a simple way to decide.

SituationUse
A new idea or topicA new <p>
A line inside the same thought, like an address or a poem<br /> inside one <p>

We will look at line breaks properly in the next lesson.

Try It Yourself​

Grab your editor and give this a go.

  1. Create a file called about-me.html.
  2. Write an <h1> with your name.
  3. Add three paragraphs: who you are, what you are learning, and what you want to build.
  4. Add a <style> block that sets line-height: 1.7 and max-width: 60ch on p.
  5. Open the file in your browser and read it out loud. Does it feel comfortable?

If it does, you are already writing like a web developer. πŸŽ‰


Quick Recap​

Click a question to check your answer.

1. Which tag creates a paragraph?

The <p> tag.

2. Why do extra spaces in my code not show up in the browser?

Browsers collapse whitespace. Any run of spaces, tabs, and line breaks turns into a single space.

3. Is a paragraph a block-level or inline element?

Block-level. It starts on a new line and stretches across the available width.

4. What should you use instead of empty paragraphs to add space?

CSS properties such as margin or padding.

5. Can you place a <p> inside another <p>?

No. The browser closes the first paragraph automatically, so nesting does not work.

Key Takeaways​

  • Use <p> for blocks of text, and give each idea its own paragraph.
  • Paragraphs are block elements with default space above and below.
  • Browsers collapse extra spaces and blank lines, so use tags and CSS to control layout.
  • Do not use empty paragraphs for spacing, and do not nest one paragraph in another.
  • A little CSS, like line-height and max-width, makes text much nicer to read.

You have got the hang of paragraphs. Next up, learn how to break lines without starting a new paragraph in Line Breaks.