HTML Heading 5 Element

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

Example

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

index.html

<!DOCTYPE html>
<html>
    <body>
        <h5>Hello World</h5>
    </body>
</html>

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

Default CSS for HTML h5

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

display: block;
font-size: 0.83em;
margin-block-start: 1.67em;
margin-block-end: 1.67em;
margin-inline-start: 0px;
margin-inline-end: 0px;
font-weight: bold;

Inline Style for HTML Heading 5 Element

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

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

index.html

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

Apply CSS for HTML Heading 5 Element

We can apply CSS for all Heading 5 elements using the h5 tag.

index.html

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

Conclusion

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