首頁 web前端 html教學 HTML 中的字型標籤

HTML 中的字型標籤

Sep 04, 2024 pm 04:27 PM
html html5 HTML Tutorial HTML Properties HTML tags

HTML 中的字型標籤是用來使網頁或 HTML 文件更具吸引力的最重要屬性之一。它具有更改所包含文字的大小、顏色和樣式的屬性。借助字體標籤,可以使網頁的大小、顏色和外觀採用相同的文字格式。此標籤主要作用於尺寸、面或類型和顏色等三個主要屬性。字體標籤作為 HTML 中的內嵌元素來變更 HTML 文件中區塊文字的某些功能。 內包含的文字標籤用於定義其中所包含的文字的樣式。

文法:

<font size =" " face =" " color=" ">
登入後複製
  • 以上語法狀態,字體大小是語法中的屬性,用來設定文字的具體大小。該大小可以定義為 1 到 7 之間的數字,其中 1 表示最小文本,7 表示最大文本大小。字型標籤中的face屬性用於定義HTML文件中的字型類型,而color屬性用於定義所包含文字的特定顏色。  
  • HTML ; 中使用的標籤標籤。它是使用 .. 定義的HTML 中的標籤。
<body>
<p> <font size="2" color="blue" face="Calibri"> </font>
</p>
</body>
登入後複製

此標籤也支援全域屬性和事件屬性。此外,它還支援一些其他屬性,如下所示:

Attribute Name Detail Description
Size This attribute is used to define a specific size for text in between 1 to 7.
Face or type This attribute is used to define the font type for the included text.
Color This attribute is used to show enclosed text in a different color.
Weight This attribute defines the boldness of the text of the font tag.
屬性名稱

詳細說明

尺寸 此屬性用於定義 1 到 7 之間的特定文字大小。 臉部或文字 此屬性用於定義所包含文字的字體類型。 顏色 此屬性用於以不同的顏色顯示封閉的文字。 粗細 此屬性定義字體標籤文字的粗體程度。 表> HTML 中的字型標籤範例

字體標籤在 HTML 程式碼中可以透過兩種方式使用,第一種是透過 HTML 包含字體標籤及其屬性值,第二種是使用定義屬性值作為 CSS 程式碼。兩者都會產生相同的輸出。唯一的差別在於定義屬性值。

範例#1

定義字型標籤及其屬性值:

<!DOCTYPE html>
<html>
<head>
<title>Font Tag in HTML</title>
</head>
<body>
<h2>Example of  Font Tag in HTML </h2>
<p>General  text  without any Font tag attribute value</p>
<p>
<font color="orange">Text having normal font size and font face . Only changing
font   color  </font>
</p>
<p>
<font  face="cursive">Text having different font face.</font>
</p>
<p>
<font size="3">Text with Increased font size having default font type. </font>
</p>
</body>
</html>
登入後複製
代碼:

輸出:HTML 中的字型標籤

範例#2

定義字體標籤,其屬性值透過CSS定義:

<!DOCTYPE html>
<html>
<head>
<title>Font Tag in HTML</title>
</head>
<body>
<h2>Example of Font Tag in HTML using CSS </h2>
<p>Someone’s sitting in the shade today because someone plated a tree a long time ago. </p>
<p style="color : lightgreen;"> Someone’s sitting in the shade today because someone plated a tree a long time ago.
</p>
<p style="font-family : Book Antiqua; color: blue; " > Someone’s sitting in the shade today because someone plated a tree a long time ago.
</p>
<p style="font size:3px;"> Someone’s sitting in the shade today because
someone plated a tree a long time ago.
</p>
</body>
</html>
登入後複製
代碼:

輸出:HTML 中的字型標籤

範例 #3

在此範例中,我們使用具有屬性值 size 的 Font 標籤,它將定義從最小尺寸到最大尺寸的文本,如下所示:

<!DOCTYPE html>
<html>
<head>
<title>HTML font tag</title>
</head>
<body>
<font size = "1">People may doubt what you say, but they will believe what you do.</font><br /> <br/>
<font size = "2">People may doubt what you say, but they will believe what you do.</font><br /> <br/>
<font size = "3">People may doubt what you say, but they will believe what you do.</font><br /> <br/>
<font size = "4">People may doubt what you say, but they will believe what you do.</font><br /> <br/>
<font size = "5">People may doubt what you say, but they will believe what you do.</font><br /> <br/>
<font size = "6">People may doubt what you say, but they will believe what you do.</font><br/><br/>
<font size = "7">People may doubt what you say, but they will believe what you do.</font>
</body>
</html>
登入後複製
HTML 程式碼:

輸出:HTML 中的字型標籤

範例#4

<!DOCTYPE html>
<html>
<head>
<title>HTML tag with Font Type attribute</title>
</head>
<body>
<font face = "Comic sans MS"> Correct one fault at a time. Concentrate on the one fault you want to overcome.</font><br/>
<font face = "Bernard MT Condensed" color="Red" >Correct one fault at a time. Concentrate on the one fault you want to overcome. </font><br/>
<font face = "Algerian">Correct one fault at a time. Concentrate on the one fault you want to overcome. </font><br/>
<font face = "Book Antiqua" size="5">Correct one fault at a time. Concentrate on the one fault you want to overcome. </font><br/>
<font face = "Aharoni"> Correct one fault at a time. Concentrate on the one fault you want to overcome.</font><br/>
<font face = "AR BERKLEY" >Correct one fault at a time. Concentrate on the one fault you want to overcome. </font><br/>
</body>
</html>
登入後複製
HTML 程式碼:

輸出:HTML 中的字型標籤

範例#5

<!DOCTYPE html>
<html>
<head>
<title>HTML Font tag-Color </title>
</head>
<body>
<font color = "#cc0066"><b>It is terrible thing to see and have no vision</b></font><br>
<font color = "#66ff33"><b>Today's preparation </b></font> <br>
<font color = "#0000cc"><strong>Success depends on your backbone not your wishbone.</strong></font><br />
<font color = "#cc3300"><b>Patience makes lighter what sorrow may not heal</b></font>  <br>
<font color = "#666600"><b>Hold fast to dreams, for if dreams die, life is broken winged bird that cannot fly </b></font> <br>
</body>
</html>
登入後複製
HTML 程式碼:

輸出:HTML 中的字型標籤

  • 結論
  • 用於以相同大小、顏色和麵格式顯示文字。字體標籤將透過使用 .. 顯示。標籤。
從上述資訊中,我們知道大小、字體、顏色是字體樣式的關鍵屬性。

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

本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

熱門話題

Java教學
1657
14
CakePHP 教程
1415
52
Laravel 教程
1309
25
PHP教程
1257
29
C# 教程
1230
24
HTML 中的表格邊框 HTML 中的表格邊框 Sep 04, 2024 pm 04:49 PM

HTML 表格邊框指南。在這裡,我們以 HTML 中的表格邊框為例,討論定義表格邊框的多種方法。

HTML 左邊距 HTML 左邊距 Sep 04, 2024 pm 04:48 PM

HTML 左邊距指南。在這裡,我們討論 HTML margin-left 的簡要概述及其範例及其程式碼實作。

HTML 中的巢狀表 HTML 中的巢狀表 Sep 04, 2024 pm 04:49 PM

這是 HTML 中巢狀表的指南。這裡我們討論如何在表中建立表格以及對應的範例。

HTML 表格佈局 HTML 表格佈局 Sep 04, 2024 pm 04:54 PM

HTML 表格佈局指南。在這裡,我們詳細討論 HTML 表格佈局的值以及範例和輸出。

HTML 輸入佔位符 HTML 輸入佔位符 Sep 04, 2024 pm 04:54 PM

HTML 輸入佔位符指南。在這裡,我們討論 HTML 輸入佔位符的範例以及程式碼和輸出。

HTML 有序列表 HTML 有序列表 Sep 04, 2024 pm 04:43 PM

HTML 有序列表指南。在這裡我們也分別討論了 HTML 有序列表和類型的介紹以及它們的範例

您如何在PHP中解析和處理HTML/XML? 您如何在PHP中解析和處理HTML/XML? Feb 07, 2025 am 11:57 AM

本教程演示瞭如何使用PHP有效地處理XML文檔。 XML(可擴展的標記語言)是一種用於人類可讀性和機器解析的多功能文本標記語言。它通常用於數據存儲

HTML onclick 按鈕 HTML onclick 按鈕 Sep 04, 2024 pm 04:49 PM

HTML onclick 按鈕指南。這裡我們分別討論它們的介紹、工作原理、範例以及各個事件中的onclick事件。

See all articles