如何在HTML中包含強調文字?
在HTML中強調文字內容,我們使用<em>標籤。它與<italic>標籤相同。它有開始和結束標籤,<em></em>。<em>標籤是一個短語標籤。它顯示為強調文字。
<em>Emphasized text</em>
出現在<em>標籤的開始和結束標籤之間的文字將以斜體形式顯示。斜體<i>標籤和強調<em>標籤的主要區別在於,強調標籤在語義上強調部分單詞,而<i>標籤則以斜體顯示文字,表示不同的語氣。<em>標籤的效果可以透過CSS屬性實現。
語法
以下是CSS中<em>標籤的用法:
em {
font-style: italic;
}
<em>標籤支援全域性屬性和事件屬性。
<em>元素放置在<body>標籤內。
它用於將文字與其餘內容隔開。
我們還可以透過應用CSS來更改<em>標籤的行為。
<em>屬性不儲存值。
所有瀏覽器都支援<em>標籤。
示例
以下示例演示了在HTML中使用<em>標籤:
<!DOCTYPE html> <html> <body> <h1>Demonstrating em element</h1> <p>HTML stands for <em>Hyper Text Markup Language </em> created by <em>Berners-Lee </em>in late 1991 </p> <p>HTML is designed to create <em>Web Pages</em> </p> </body> </html>
示例
以下是另一個帶有title屬性的<em>標籤示例,用於建立強調文字。
<!DOCTYPE html> <html> <head> <title> Inserting Emphasized text using HTML </title> </head> <body style="text-align: center;"> <h1 style="color:red;"> HTML Tutorial </h1> <h3> Inserting Emphasized text using HTML </h3> <em title="Emphasized text"> Welcome To TutorialsPoint </em> </body> </html>
示例
以下是使用CSS的<em>標籤示例。
<!DOCTYPE html>
<html>
<head>
<style>
em {
font-style: italic;
background-color: yellow;
text-emphasis-color: green;
text-emphasis-style: "*";
}
</style>
</head>
<body>
<p>An Emphasized element can be displayed like this:</p>
<em>HTML Tutorial</em>
<p>To see the effects, Change the default CSS settings .</p>
</body>
</html>
示例
還有一個text-emphasis屬性也可以用來突出顯示文字,讓我們看看使用CSS的text-emphasis示例。以下示例演示了text-emphasis屬性。
<!DOCTYPE html>
<html>
<head>
<style>
p.ex1 {
text-emphasis: filled;
}
p.ex2 {
text-emphasis: open;
}
p.ex3 {
text-emphasis: double-circle red;
}
p.ex4 {
text-emphasis: triangle blue;
}
</style>
</head>
<body>
<h1>Demonstrating text-emphasis Property</h1>
<p class="ex1">Welcome To My World</p>
<p class="ex2">It's a Beautiful World</p>
<p class="ex3">Learn HTML with Fun</p>
<p class="ex4">Door's Open</p>
</body>
</html>
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP