HTML <p> 标籤

Paglalarawan at Paggamit

<p> tag sa paglalarawan ng pahayag.

Ang browser ay magpapalakas ng awtomatikong isang walang laman na linya sa bawat <p> Magdagdag ng isang walang laman na linya sa harap at likod ng elemento.

Mga Payo:Gamit ang CSS Itaas ang estilo ng pahayag

Mga pangkatuwang Basahin:

Tuturo ng HTML:HTML 段落

Manwal ng HTML DOM:Objeto ng Paragraph

Halimbawa

Mga Halimbawa 1

Tandaan ang pahayag tulad nang ito:

<p>Ang teksto na ito ay nasa loob ng pahayag.</p>

親自試一試

Mga Halimbawa 2

Ayusin ang teksto ng pahayag (gamit ang CSS):

<p style="text-align:right">Ito ang ilang teksto sa loob ng pahayag.</p>

親自試一試

Mga Halimbawa 3

Ginagamit ang CSS upang magset ng estilo ng pahayag:

<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>

親自試一試

範例 4

更多段落:

<p>
在源代碼中,
這一段
包含很多行,
但瀏覽器
忽略它。
</p>

親自試一試

範例 5

HTML 中的詩歌問題:

<p>
  Departing from Baidi in the colorful clouds between.
  One day's journey brings me back to Jiangling.
  The monkeys on both banks keep crying.
  Boats have passed over ten thousand mountains.
</p>

親自試一試

全局屬性

<p> 標籤還支持 HTML 中的全局屬性

事件屬性

<p> 標籤還支持 HTML 中的事件屬性

默認的 CSS 設置

大多數瀏覽器將使用以下默認值顯示 <p> 元素:

p {
  display: block;
  margin-top: 1em;
  margin-bottom: 1em;
  margin-left: 0;
  margin-right: 0;
}

親自試一試

瀏覽器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持