← Back to HTML Course | Chapter 1: Introduction & Basics | Lesson 7 of 11

HTML Paragraphs

कल्पना कीजिए एक story पढ़ने की कोशिश करना जहां text कभी रुकता ही नहीं। कोई breaks नहीं, कोई pauses नहीं, बस अक्षरों की एक अंतहीन दीवार। आपकी आँखें एक मिनट में थक जाएंगी। HTML paragraphs आपके webpage के blocks हैं। जब भी आप text को एक paragraph tag के अंदर package करते हैं, browser अपने आप उसके ऊपर और नीचे खाली स्थान जोड़कर उसे थोड़ी breathing room देता है। इससे आपके articles, tool instructions, और explanations साफ-सुथरे, structured, और आँखों के लिए आरामदायक बने रहते हैं।
Syntax
markup
<p>Paragraph text</p>

बुनियादी Paragraph Tag

p tag का उपयोग text के एक block को define करने के लिए किया जाता है। यह एक block-level element है, जिसका मतलब है कि यह हमेशा नई line पर शुरू होगा और उपलब्ध पूरी width ले लेगा, और उसके बाद के content को नीचे धकेल देगा।

Note: अपने सभी body text को body के अंदर ढीला छोड़ने के बजाय p tags में लपेटें।
Warning: Paragraph tags अपने आप एक नई line पर शुरू होते हैं, इसलिए इन्हें छोटे inline text adjustments के लिए उपयोग न करें।

उदाहरण: The Basic Paragraph Tag

markup
<p>This is the first paragraph.</p>
<p>This is the second paragraph, starting on a new line below the first.</p>

HTML Whitespace को कैसे handle करता है

HTML का एक अनोखा नियम है: यह कई spaces और line breaks को एक single space में collapse कर देता है। चाहे आप अपने code editor के अंदर Spacebar या Enter key कितनी भी बार दबाएं, ब्राउज़र extra whitespace को ignore कर देगा।

Note: अपने code editor के अंदर कई spaces टाइप करके text spacing को format करने की कोशिश न करें।
Warning: आपके source code में extra spaces flatten हो जाएंगे, जो custom text indentations को बिगाड़ सकता है।

उदाहरण: How HTML Handles Whitespace

markup
<p>This   text has     multiple spaces
and a line break
but the browser displays it as one single space.</p>

br से Line Breaks बनाना

कभी-कभी आप text की एक नई line शुरू करना चाहते हैं, लेकिन आप अपने बड़े default spacing के साथ बिल्कुल नया paragraph शुरू नहीं करना चाहते। br tag एक manual line break की तरह काम करता है जो text को सीधे अगली line पर ले जाता है।

Note: br tag एक empty element है, यानी इसका कोई closing tag नहीं होता।
Warning: खाली vertical spaces बनाने के लिए br tags की chain का उपयोग करने से बचें; इसकी जगह CSS margins का उपयोग करें।

उदाहरण: Creating Line Breaks with br

markup
<p>Roses are red<br>
Violets are blue</p>

pre से Formatting Preserve करना

अगर आप computer code, poetry, या text art जैसा content display कर रहे हैं, तो आपको ब्राउज़र से हर space और line break को respect कराना होगा। pre tag ब्राउज़र को निर्देश देता है कि text को बिल्कुल वैसे ही display करे जैसे वह टाइप किया गया है, एक fixed-width font का उपयोग करते हुए।

Note: precise alignment पर निर्भर raw text layouts display करते समय pre tag का उपयोग करें।
Warning: Preformatted text अपने आप wrap नहीं होता, इसलिए अगर यह बहुत लंबा हो तो mobile screens के किनारे से बाहर निकल सकता है।

उदाहरण: Preserving Formatting with pre

markup
<pre>
This    text
    keeps its   spacing
        and line breaks exactly.
</pre>

Paragraphs के लिए Invalid Nesting Rules

HTML standards के अनुसार, paragraph tag में सिर्फ inline text और media होना चाहिए। इसमें headings, lists, या div tags जैसे अन्य block-level elements नहीं हो सकते। किसी paragraph के अंदर block element nest करना आपकी HTML validation को तोड़ देता है।

Note: अगर आपको block elements के लिए container चाहिए, तो paragraph tag के बजाय div tag का उपयोग करें।
Warning: अगर आप एक paragraph के अंदर एक heading डालते हैं, तो modern browsers जबरदस्ती आपके paragraph को बंद कर देंगे और आपका layout टूट जाएगा।

उदाहरण: Invalid Nesting Rules for Paragraphs

markup
<p>
  Some text before
  <div>A div tag cannot go inside a paragraph</div>
</p>
Live Example
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
🔒

Chapter Quiz — Complete all 11 topics to unlock

0/11 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.