HTML Heading 4 Element

HTML Heading 4 <h4> tag is used to define heading of type 4 in an HTML document.

Example

A simple Heading 4 element is shown in the following example.

index.html

</>
Copy
<!DOCTYPE html>
<html>
    <body>
        <h4>Hello World</h4>
    </body>
</html>

Note: HTML Heading 4 element starts with the tag <h4> and ends with an end tag </h4>.

Default CSS for HTML <h4>

By default, following CSS properties are set for a Heading 4 element.

</>
Copy
display: block;
margin-block-start: 1.33em;
margin-block-end: 1.33em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;

Inline Style for HTML Heading 4 Element

We can change the style of Heading 4 element through inline styling using style attribute.

In the following example, we have set the color as red for the Heading 4 element.

index.html

</>
Copy
<!DOCTYPE html>
<html>
    <body>
        <h4 style="color:red;">Hello World</h4>
    </body>
</html>

Apply CSS for HTML Heading 4 Element

We can apply CSS for all Heading 4 elements using the h4 tag.

index.html

</>
Copy
<!DOCTYPE html>
<html>
    <head>
        <style>
            h4 {
              color:red;
            }
          </style>
    </head>
    <body>
        <h4>Hello World</h4>
    </body>
</html>

Conclusion

In this HTML Tutorial, we learned about HTML <h4> tag and went through different examples that cover defining an HTML Heading 4 element, and styling it.