#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
HTML Fundamentals

HTML Paragraph

The <p> element marks a paragraph: a block of related sentences that belong together. Browsers display each paragraph on its own line with space above and below it. Paragraphs are the basic unit of body text on almost every page, and using them properly makes content easier to read, style and understand for screen readers and search engines.

How the browser treats whitespace in a paragraph

HTML collapses whitespace. Line breaks, tabs and multiple spaces inside a paragraph are shown as a single space, and the text wraps to fit the container. So how you format the source code does not change how the text appears.

<p>
  This sentence is split
      across several lines
  in the source code.
</p>
<!-- Displays as: This sentence is split across several lines in the source code. -->

<p>Second paragraph. It starts on a new line with space above it.</p>

This is why you should not try to create layout with extra spaces or empty lines in HTML. Spacing belongs in CSS.

Line breaks, rules and preformatted text

Sometimes a line break is part of the content itself, such as in a postal address or a poem. That is where <br> fits. When the content changes topic within a section, <hr> marks a thematic break. And when whitespace must be kept exactly, such as in code or ASCII art, use <pre>.

An address is a good example: writing each line followed by <br> keeps the lines together in one paragraph while still breaking them where the postal format requires. A short table of settings written inside <pre> keeps its column alignment, because that element displays spaces and line breaks exactly as typed, usually in a monospace font.

Inline elements that live inside paragraphs

Paragraphs hold text and inline elements. Common ones are <strong> for important text, <em> for stressed emphasis, <a> for links, <code> for short code, <abbr> for abbreviations, <mark> for highlighted text and <small> for side notes like fine print. These keep their meaning even when restyled, which plain bold or italic CSS does not.

What a paragraph cannot contain

A paragraph cannot contain block-level elements such as <div>, lists, tables, headings or another <p>. If you write one inside, the browser silently ends the paragraph before it. Your CSS and JavaScript then work on a different structure from the one you wrote. When you need a paragraph followed by a list, close the paragraph first and put the list after it.

The empty paragraph habit

A widespread mistake is stacking empty paragraphs or several <br> tags to push content down the page. It produces uneven gaps across devices, adds noise for screen readers, which may announce blank lines, and breaks as soon as the font size changes. Control space with CSS instead:

p {
  margin-block: 0 1rem;   /* space only below each paragraph */
  line-height: 1.6;
  max-width: 65ch;        /* comfortable line length */
}

The ch unit is roughly the width of one character, so 65ch keeps lines from stretching uncomfortably wide on large screens.

Writing paragraphs that read well

Keep each paragraph to one main idea. On screens, short paragraphs of two to four sentences are easier to scan than long walls of text. Start with the key point so readers who skim still get the message, and use headings between groups of paragraphs so people can jump to what they need.

Recap

  • Use <p> for blocks of related sentences.
  • Extra spaces and line breaks in the source collapse to one space.
  • Use <br> only when the break is part of the content.
  • Never nest blocks inside a paragraph; space it with CSS margins.

Ready to master real-world web development?

Learn HTML, CSS3, Bootstrap and JavaScript hands-on with mentor-led sessions.

Explore Course