Style a Header with CSS



To style a header with CSS, we can use various CSS properties to make it look attractive. In this article, we will learn and understand to style the header using diferent CSS properties.

Style header with CSS

Example

Here is the complete example code implementing above mentioned steps.

<!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>

Conclusion

In this article we have understood how to style a header with CSS. We have used font-style, font-family, color, text-align and background-color to style the header.

Updated on: 2024-07-23T17:38:15+05:30

10K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements