首頁  >  文章  >  web前端  >  HTML 文字格式標籤

HTML 文字格式標籤

王林
王林原創
2024-09-04 16:16:32766瀏覽

格式化文字是現代網路網頁的重要組成部分;即使我們僅限於使用文字為主的網頁瀏覽器,也可以使用文字格式(例如大小、方向等)。透過現代 HTML 修訂版,可以使用大量 HTML 標籤來讓文字外觀符合您的喜好。

使用 HTML 標籤格式化文字

下面我們將討論一些用於格式化文字的重要 HTML 標籤:

1.將 HTML 中的文字格式設定為粗體

HTML 有兩個不同的標籤將文字設定為粗體外觀。一個是。另一個是同時兩者產生相似的輸出。 tag是一個實體標籤,僅用於以粗體顯示文本,且在瀏覽器中不會添加任何重要性值。

範例

代碼:

<!DOCTYPE>
<html>
<body>
<p> <b>Here is some text in bold. </b></p>
</body>
</html>

輸出:

HTML 文字格式標籤

另一方面,標籤被視為邏輯標籤,它用於通知瀏覽器標籤中的文字具有一定的邏輯重要性。

範例

代碼:

<!DOCTYPE>
<html>
<body>
<p> <strong>This is an important content formatted using the strong tag </strong>, and this is just
normally formatted text</p>
</body>
</html>

輸出:

HTML 文字格式標籤

2.在 HTML5 中將文字設定為斜體

就像將文字設定為粗體一樣,您可以使用 標籤和 標籤在 HTML5 上將文字設定為斜體。

使用 ;就像使用 一樣,文字物理顯示為斜體,標籤 同時也將文字顯示為斜體,讓瀏覽器知道它具有語義重要性。

範例

代碼:

<!DOCTYPE>
<html>
<body>
<p> <i> This is the first para in italic text. </i></p>
<p> <em> This content is made italics with the em tag</em>, This is normal text </p>
</body>
</html>

輸出:

HTML 文字格式標籤

3.使用 HTML 程式碼突顯文字

如果您想使用螢光筆效果來突出顯示某些文本,則可以使用標籤可以使用;使用預設CSS,該標籤會將文本背景設為黃色,幫助您輕鬆吸引訪客對該文本的注意力。

範例

代碼:

<!DOCTYPE>
<html>
<body>
<h3> This text uses <mark> Mark</mark> tag to highlight text on the page </h3>
</body>
</html>

輸出:

HTML 文字格式標籤

4. HTML 中的文字下劃線

HTML 標籤 可用於在文字中新增底線。請注意不要在藍色文字中使用下劃線,因為它可能會讓訪客誤以為該文字是連結。

範例

代碼:

<!DOCTYPE>
<html>
<body>
<p> <u> This is Text with underline tag. </u> </p>
</body>
</html>

輸出:

HTML 文字格式標籤

5.有刪除線的文字

如果您需要在文字中繪製水平線,請標記 可以使用。淹沒的線很細,因此仍然可以輕鬆閱讀它所跨越的文字。

 範例

代碼:

<!DOCTYPE>
<html>
<body>
<p> <strike> Here is a sentence with strike through text </strike>. </p>
</body>
</html>

輸出:

HTML 文字格式標籤

6.在 HTML 中以等寬字體書寫

當您想要引用某些內容或想要在瀏覽器中顯示某些程式碼時,使用等寬字體會很有用。等寬字體程式碼,顧名思義,使每個字元的寬度相同。要在瀏覽器上取得它,我們必須使用 標籤。

 範例

代碼:

<!DOCTYPE>lt;html>
<body>
<p> This is normal text. <tt>This is some sample text in monospace fonts, neat. </tt> </p>
</body>
</html>

輸出:

HTML 文字格式標籤

7. HTML 中的下標文字

在數學和化學中,在許多情況下使用下標是絕對要求。在一般寫作中,您也可能會遇到適合使用下標文字的情況。在 HTML 中, 下的任何文字都可以包含在 中。標籤將在瀏覽器中用作下標。

範例

代碼:

<!DOCTYPE>
<html>
<body>
<p> This is normal text <sub>Notice something different with this text? </sub> </p>
</body>
</html>

輸出:

HTML 文字格式標籤

8.已刪除 HTML5 中的文字

;標籤用作告訴瀏覽器文字內的文字已刪除的邏輯方式。請記住,對於使用者來說,顯示的文字與刪除線標籤中的標籤相同,這表示它以刪除線格式顯示。

 範例 

代碼:

<!DOCTYPE>
<html>
<body>
<p> This is normal text <del> This is text between del tag. </del> </p>
</body>
</html>

輸出:

HTML 文字格式標籤

9. Superscript Text formatting in HTML5

Text in tag is shown in superscript. This is useful in math, chemistry and other places where math is involved. You can use the tag when citing with adding in-page links with too.

Example

Code:

<!DOCTYPE>
<html>
<body>
<p> This is Normal text<sup> This text is in superscript. </sup> </p>
</body>
</html>

Output:

HTML 文字格式標籤

10. Making Text size larger with HTML formatting

In cases where you need some text in a larger size on the screen, but you don’t want to use a heading or increase the font size with a tag, use content between this tag will be displayed in noticeably larger text size.

Example

Code:

<!DOCTYPE>
<html>
<body>
<p> This is Normal text <big> This text in in larger size. </big> </p>
</body>
</html>

Output:

HTML 文字格式標籤

11. Making Text smaller with HTML

Like the tag , you can use to make text smaller on the screen without using CSS or headings.

Example

Code:

<!DOCTYPE>
<html>
<body>
<p> This is Normal text <small> the size of this text is smaller </small> </p>
</body>
</html>

Output:

HTML 文字格式標籤

Conclusion

Now that you have learned how the formatting of text in HTML works, you should be able to design pages with correct and professional-looking text layout and formatting. It would help if you used normal text and formatting where possible; using custom formatting only when needed gives your pages a neat look. The normal text size is important too, too small, and the readably will be affected negatively, and if it is too large, there will be less information on the screen at once.

以上是HTML 文字格式標籤的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
上一篇:HTML 樣式表下一篇:HTML 樣式表