: The Paragraph Element - HTML: HyperText Markup Language
Có thể bạn quan tâm
- References
- HTML
- Elements
- <p>
- English (US)
- Remember language
- Deutsch
- Español
- Français
- 日本語
- 한국어
- Português (do Brasil)
- Русский
- 中文 (简体)
- 正體中文 (繁體)
- Try it
- Attributes
- Accessibility
- Examples
- Styling paragraphs
- Technical summary
- Specifications
- Browser compatibility
- See also
- HTML
- Beginner's tutorials
- Your first website: Creating the content
- Structuring content with HTML
- Basic HTML syntax
- What's in the head? Webpage metadata
- Headings and paragraphs in HTML
- Emphasis and importance
- Lists
- Structuring documents
- Advanced text features
- Creating links
- Challenge: Marking up a letter
- Challenge: Structuring a page of content
- HTML images
- HTML video and audio
- Challenge: Mozilla splash page
- HTML table basics
- HTML table accessibility
- Challenge: Structuring a planet data table
- Forms and buttons in HTML
- Debugging HTML
- Guides
- Content categories
- Block-level elements
- Inline elements
- Quirks Mode and Standards Mode
- Date and time formats used in HTML
- Constraint validation
- Microdata
- Microformats
- Viewport meta tag
- Allowing cross-origin use of images and canvas
- References
- HTML elements
- <a>
- <abbr>
- <acronym> Deprecated
- <address>
- <area>
- <article>
- <aside>
- <audio>
- <b>
- <base>
- <bdi>
- <bdo>
- <big> Deprecated
- <blockquote>
- <body>
- <br>
- <button>
- <canvas>
- <caption>
- <center> Deprecated
- <cite>
- <code>
- <col>
- <colgroup>
- <data>
- <datalist>
- <dd>
- <del>
- <details>
- <dfn>
- <dialog>
- <dir> Deprecated
- <div>
- <dl>
- <dt>
- <em>
- <embed>
- <fencedframe> Experimental
- <fieldset>
- <figcaption>
- <figure>
- <font> Deprecated
- <footer>
- <form>
- <frame> Deprecated
- <frameset> Deprecated
- <h1>
- <head>
- <header>
- <hgroup>
- <hr>
- <html>
- <i>
- <iframe>
- <img>
- <input>
- <ins>
- <kbd>
- <label>
- <legend>
- <li>
- <link>
- <main>
- <map>
- <mark>
- <marquee> Deprecated
- <menu>
- <meta>
- <meter>
- <nav>
- <nobr> Deprecated
- <noembed> Deprecated
- <noframes> Deprecated
- <noscript>
- <object>
- <ol>
- <optgroup>
- <option>
- <output>
- <p>
- <param> Deprecated
- <picture>
- <plaintext> Deprecated
- <portal> Experimental
- <pre>
- <progress>
- <q>
- <rb> Deprecated
- <rp>
- <rt>
- <rtc> Deprecated
- <ruby>
- <s>
- <samp>
- <script>
- <search>
- <section>
- <select>
- <slot>
- <small>
- <source>
- <span>
- <strike> Deprecated
- <strong>
- <style>
- <sub>
- <summary>
- <sup>
- <table>
- <tbody>
- <td>
- <template>
- <textarea>
- <tfoot>
- <th>
- <thead>
- <time>
- <title>
- <tr>
- <track>
- <tt> Deprecated
- <u>
- <ul>
- <var>
- <video>
- <wbr>
- <xmp> Deprecated
- Global attributes
- accesskey
- anchor Experimental Non-standard
- autocapitalize
- autocorrect Experimental
- autofocus
- class
- contenteditable
- data-*
- dir
- draggable
- enterkeyhint
- exportparts
- hidden
- id
- inert
- inputmode
- is
- itemid
- itemprop
- itemref
- itemscope
- itemtype
- lang
- nonce
- part
- popover
- slot
- spellcheck
- style
- tabindex
- title
- translate
- virtualkeyboardpolicy Experimental
- writingsuggestions
- Attributes
- accept
- autocomplete
- capture
- crossorigin
- dirname
- disabled
- elementtiming
- for
- max
- maxlength
- min
- minlength
- multiple
- pattern
- placeholder
- readonly
- rel
- required
- size
- step
- <input> types
- <input type="button">
- <input type="checkbox">
- <input type="color">
- <input type="date">
- <input type="datetime-local">
- <input type="email">
- <input type="file">
- <input type="hidden">
- <input type="image">
- <input type="month">
- <input type="number">
- <input type="password">
- <input type="radio">
- <input type="range">
- <input type="reset">
- <input type="search">
- <input type="submit">
- <input type="tel">
- <input type="text">
- <input type="time">
- <input type="url">
- <input type="week">
- Try it
- Attributes
- Accessibility
- Examples
- Styling paragraphs
- Technical summary
- Specifications
- Browser compatibility
- See also
The <p> HTML element represents a paragraph. Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields.
Paragraphs are block-level elements, and notably will automatically close if another block-level element is parsed before the closing </p> tag. See "Tag omission" below.
Try it
Attributes
This element only includes the global attributes.
Note: The align attribute on <p> tags is obsolete and shouldn't be used.
Accessibility
Breaking up content into paragraphs helps make a page more accessible. Screen-readers and other assistive technology provide shortcuts to let their users skip to the next or previous paragraph, letting them skim content like how white space lets visual users skip around.
Using empty <p> elements to add space between paragraphs is problematic for people who navigate with screen-reading technology. Screen readers may announce the paragraph's presence, but not any content contained within it — because there is none. This can confuse and frustrate the person using the screen reader.
If extra space is desired, use CSS properties like margin to create the effect:
cssp { margin-bottom: 2em; /* increase white space after a paragraph */ }Examples
HTML
html<p> This is the first paragraph of text. This is the first paragraph of text. This is the first paragraph of text. This is the first paragraph of text. </p> <p> This is the second paragraph. This is the second paragraph. This is the second paragraph. This is the second paragraph. </p>Result
Styling paragraphs
By default, browsers separate paragraphs with a single blank line. Alternate separation methods, such as first-line indentation, can be achieved with CSS:
HTML
html<p> Separating paragraphs with blank lines is easiest for readers to scan, but they can also be separated by indenting their first lines. This is often used to take up less space, such as to save paper in print. </p> <p> Writing that is intended to be edited, such as school papers and rough drafts, uses both blank lines and indentation for separation. In finished works, combining both is considered redundant and amateurish. </p> <p> In very old writing, paragraphs were separated with a special character: ¶, the <i>pilcrow</i>. Nowadays, this is considered claustrophobic and hard to read. </p> <p> How hard to read? See for yourself: <button data-toggle-text="Oh no! Switch back!"> Use pilcrow for paragraphs </button> </p>CSS
cssp { margin: 0; text-indent: 3ch; } p.pilcrow { text-indent: 0; display: inline; } p.pilcrow + p.pilcrow::before { content: " ¶ "; }JavaScript
jsdocument.querySelector("button").addEventListener("click", (event) => { document.querySelectorAll("p").forEach((paragraph) => { paragraph.classList.toggle("pilcrow"); }); [event.target.innerText, event.target.dataset.toggleText] = [ event.target.dataset.toggleText, event.target.innerText, ]; });Result
Technical summary
Content categories | Flow content, palpable content. |
---|---|
Permitted content | Phrasing content. |
Tag omission | The start tag is required. The end tag may be omitted if the <p> element is immediately followed by an <address>, <article>, <aside>, <blockquote>, <details>, <div>, <dl>, <fieldset>, <figcaption>, <figure>, <footer>, <form>, h1, h2, h3, h4, h5, h6, <header>, <hgroup>, <hr>, <main>, <menu>, <nav>, <ol>, <pre>, <search>, <section>, <table>, <ul> or another <p> element, or if there is no more content in the parent element and the parent element is not an <a>, <audio>, <del>, <ins>, <map>, <noscript> or <video> element, or an autonomous custom element. |
Permitted parents | Any element that accepts flow content. |
Implicit ARIA role | paragraph |
Permitted ARIA roles | Any |
DOM interface | HTMLParagraphElement |
Specifications
Specification |
---|
HTML Standard # the-p-element |
Browser compatibility
BCD tables only load in the browser
See also
- <hr>
- <br>
Help improve MDN
Was this page helpful to you?YesNoLearn how to contribute.This page was last modified on Jul 26, 2024 by MDN contributors.
View this page on GitHub • Report a problem with this contentTừ khóa » Html P Tag Alternative
-
HTML Tags For Text - Flavio Copes
-
Is The
Tag Ever An Undesirable Alternative To TheTag?
Need Paragraph Tag Alternative (for Image Groups) - HTML & CSS
" Tag Instead Of "
" Tag Or "
Why Did The Tutor Put A "" Tag Instead Of "
" Tag Or "
HTML P Tag - W3Schools
HTML Small Tag - W3Schools
HTML 5
Tag
WebD2: Common HTML Tags - University Of Washington
HTML:
Tag - TechOnTheNet
What Is The Best Alternative To Repetitive Typing Of
Tags In HTML ...Semantic HTML Guide – 10 Alternatives To Using Divs
How To Avoid A New Line With Tag? - GeeksforGeeks
Titles, Subtitles And Paragraphs: HTML H1 Tags And P - Nestify
HTML P Tag - Learn HTML | W3Docs
Copyright © 2022 | Thiết Kế Truyền Hình Cáp Sông Thu