如何在HTML中下劃線文字?
下劃線文字用於幫助吸引人們對文字的注意。
我們使用<u>標籤在HTML中下劃線文字。它表示網頁內容中與其他文字不同的樣式的文字。
我們也可以使用style屬性在HTML中下劃線文字。style屬性指定元素的內聯樣式。此屬性與HTML <p>標籤一起使用,並使用CSS屬性text-decoration屬性。
語法
以下是HTML中下劃線文字的語法。
<u>The content to be underlined</u>
示例
以下是HTML中下劃線文字的示例程式。
<!DOCTYPE html> <html> <head> </head> <body> <p>DLF stands for <u>Delhi Land and Finance </u>. <br> Delhi Land and Finance is one of the largest commercial real estate developer in India.</p> </body> </html>
示例
在下面的示例中,我們對<h1>元素內的文字進行了下劃線。
<!DOCTYPE html> <html> <head> <title>HTML u tag</title> </head> <body> <h1><u>we are underlining the text inside the '<h>' element.</u></h1> </body> </html>
使用內聯CSS下劃線文字
使用CSS屬性下劃線文字。此屬性在<p>標籤內使用。
語法
以下是使用CSS屬性下劃線文字的語法。
<p style="text decoration:underline;">The content to be underlined</p>
示例
以下是使用CSS屬性下劃線文字的示例程式。
<!DOCTYPE html> <html> <head> </head> <body> <p>DLF stands for</p><p style="text-decoration:underline;">Delhi Land and Finance. </p> <p> Delhi Land and Finance is one of the largest commercial real estate developer in India.</p> </body> </html>
廣告