View video tutorial

HTML Heading Elements

HTML

Header of a section, article, paragraph or anything lead the topic.

HTML Heading elements


Heading content defines the header of a section.

Heading elements are

<h1>, <h2>, <h3>, <h4>, <h5>, <h6>.

Example <h1> - <h6>

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8" />
    <title>HTML heading tags example</title>
    <style>
        .mydiv {
            background-color: white;
            padding: 50px;
            margin: 10px;
        }

        button {
            padding: 10px;
        }
    </style>
</head>
<body>
    <div class="mydiv">
        <h1>Heading One</h1>
        <h2>Heading One</h2>
        <h3>Heading One</h3>
        <h4>Heading One</h4>
        <h5>Heading One</h5>
        <h6>Heading One</h6>
    </div>
    <button onclick="myfunc()">Toggle Style</button>
    <script>
        let element = document.querySelector(".mydiv");
        element.style.backgroundColor = 'white';
        function myfunc() {
            if (element.style.backgroundColor == 'white') {
                element.style.backgroundColor = '#d1f1f1';
            } else {
                element.style.backgroundColor = 'white';
            }
        }
    </script>
</body>
</html>
Try it Now »

Copy code and click on the "Try it Now" button to see how it works.