如何在 HTML 中顯示從右到左的文字?


direction 屬性指定了網頁塊元素內的文字方向。

我們使用 style 屬性在 HTML 中設定文字方向。style 屬性為塊內元素指定一個內聯樣式。style 屬性與 CSS 屬性 direction 一起使用,為文字設定方向。

語法

以下是使用 CSS 屬性設定文字方向(從右到左)的語法。

<p style = "direction: rtl;">The text…</p>

示例

以下示例程式用於設定 HTML 中 <p> 元素的方向。

<!DOCTYPE html> <html> <head> </head> <body> <p style = "direction: rtl;"> whiteboards are so often at the core of a collaborative process </p> </body> </html>

示例

以下示例程式用於設定 HTML 中 <h2> 元素的方向。

<!DOCTYPE html> <html> <head> </head> <body> <h2 style = "direction: rtl;"> Hallowen season it is... </h2> </body> </html>

示例

以下示例程式用於設定 HTML 中 <ul> 元素的方向。

<!DOCTYPE html> <html> <head> </head> <body> <ul style = "direction: rtl;"> <li>Coffee</li> <li>Tea</li> <li>Milk</li> </ul> </body> </html>

更新時間:11-11-2022

2K+ 次瀏覽

開啟您的 職業生涯

透過完成課程獲得認證

開始
廣告
© . All rights reserved.