如何使用 HTML 從右到左顯示文字?


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

我們在 HTML 中使用 style 屬性來設定文字方向。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>

更新於:2022 年 11 月 11 日

2,000+ 次觀看

開啟您的職業生涯

透過完成課程獲得認證

開始吧
廣告
© . All rights reserved.