HTML- <p> -Tag
Beispiel
Ein Absatz ist wie folgt gekennzeichnet:
<p>This is some text in a paragraph.</p>
Weitere „Probieren Sie es selbst“-Beispiele weiter unten.
Definition und Verwendung
Das <p>
Tag definiert einen Absatz.
<p>
Browser fügen vor und nach jedem Element automatisch eine einzelne Leerzeile ein .
Tipp: Verwenden Sie CSS, um Absätze zu formatieren .
Browser-Unterstützung
Element | |||||
---|---|---|---|---|---|
<p> | Yes | Yes | Yes | Yes | Yes |
Globale Attribute
Das <p>
Tag unterstützt auch die globalen Attribute in HTML .
Ereignisattribute
Das <p>
Tag unterstützt auch die Ereignisattribute in HTML .
Mehr Beispiele
Beispiel
Text in einem Absatz ausrichten (mit CSS):
<p style="text-align:right">This is some text in a paragraph.</p>
Beispiel
Absätze mit CSS gestalten:
<html>
<head>
<style>
p {
color: navy;
text-indent: 30px;
text-transform: uppercase;
}
</style>
</head>
<body>
<p>Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
deserunt mollit anim id est laborum.</p>
</body>
</html>
Beispiel
Mehr zu Absätzen:
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
Beispiel
Gedichtprobleme in HTML:
<p>
My Bonnie lies over the ocean.
My Bonnie lies over the sea.
My
Bonnie lies over the ocean.
Oh, bring back my Bonnie to me.
</p>
Verwandte Seiten
HTML-Tutorial: HTML-Absätze
HTML-DOM-Referenz: Paragraph-Objekt
Standard-CSS-Einstellungen
Die meisten Browser zeigen das <p>
Element mit den folgenden Standardwerten an:
Beispiel
p {
display: block;
margin-top: 1em;
margin-bottom: 1em;
margin-left: 0;
margin-right: 0;
}