如何使用 CSS 樣式化標題?


要使用 CSS 樣式化標題,我們可以使用各種CSS屬性使其看起來更具吸引力。在本文中,我們將學習和理解如何使用不同的 CSS 屬性來樣式化標題。

使用 CSS 樣式化標題

示例

以下是實現上述步驟的完整示例程式碼。

<!DOCTYPE html>
<html>
<head>
    <title>
        To style a header with CSS
    </title>
    <style>
        body {
            margin: 10px;
        }
        .header {
            padding: 30px;
            background-color: bisque;
        }
        .test {
            padding: 30px;
            background-color: #04af2f;
        }
        #head1 {
            font-style: oblique;
            text-align: center;
        }
        .head {
            font-family: "Segoe UI", Tahoma,
                Geneva, Verdana,
                sans-serif;
            text-align: center;
            color: white;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1 id="head1">
            Styling header with CSS
        </h1>
        <p>
            For this header, we have used 
            CSS font-style and text-align
            property to style the header.
        </p>
    </div>
    <div class="test">
        <h1 class="head">
            Welcome to Tutorials Point.
        </h1>
        <p>
            For this header, we have used 
            CSS font-family and color
            property to style the header.
        </p>
    </div>
</body>
</html>

結論

在本文中,我們瞭解瞭如何使用 CSS 樣式化標題。我們使用了 font-stylefont-familycolortext-alignbackground-color 來樣式化標題。

更新於: 2024年7月23日

9K+ 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

開始學習
廣告