HTML <p> tag
Definition og brug
<p>
tag definerer et afsnit.
Browseren tilføjer automatisk en tom linje i hver <p>
Tilføj en tom linje før og efter elementet.
Tip:Brug CSS Indstil afsnitets stil.
Se også:
HTML tutorial:HTML afsnit
HTML DOM reference manual:Paragraph-objekt
Eksempel
Eksempel 1
Mærk afsnit på denne måde:
<p>Dette er nogle tekst i afsnittet.</p>
Eksempel 2
Juster tekst i afsnittet (brug CSS):
<p style="text-align:right">Dette er nogle tekst i afsnittet.</p>
Eksempel 3
Brug CSS til at indstille afsnitets stil:
<html> <head> <style> p { color: navy; text-indent: 30px; text-transform: uppercase; } </style> </head> <body> <p>China, officially the People's Republic of China (PRC), is a country in East Asia. It is the world's second-most-populous country, with a population exceeding 1.4 billion. China spans the equivalent of five time zones and borders fourteen countries by land. With an area of nearly 9.6 million square kilometers (3,700,000 sq mi), it is the third-largest country by total land area. The country is divided into 22 provinces, five autonomous regions, four municipalities, and two semi-autonomous special administrative regions. Beijing is the national capital, while Shanghai is the most populous city and largest financial center.</p> </body> </html>
Example 4
More paragraphs:
<p> in the source code this paragraph contain many lines But browsers Ignore it. </p>
Example 5
HTML's poetry problem:
<p> Leaving the White Emperor in the colorful clouds. The journey of a thousand miles begins with a single step. The monkeys on both sides keep crying. The boat has passed over ten thousand mountains. </p>
Globale egenskaber
<p>
Etiketterne understøtter også Globale egenskaber i HTML.
eventegenskaber
<p>
Etiketterne understøtter også Eventegenskaber i HTML.
Standard CSS-indstillinger
De fleste browsere bruger følgende standardværdier til visning <p>
Element:
p { display: block; margin-top: 1em; margin-bottom: 1em; margin-left: 0; margin-right: 0; }
Browserkompatibilitet
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |