Open In App

How to create a caption for a figure element using HTML5 ?

Last Updated : 11 Jun, 2020
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

In this article, you learn how to create a caption for a figure element by using the <figcaption> tag in the document. This new tag in the HTML5 page is used to set a caption to the figure element in a document.

Syntax:
<figcaption> Figure caption </figcaption>

Example: The following example demonstrates to apply caption for a HTML figure element.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        How to define a caption 
        for a figure element?
    </title>

    <style>
        body {
            text-align: center;
        }

        h1 {
            color: green;
        }
    </style>
</head>

<body>
    <h1>GeeksforGeeks</h1>

    <h2>
        HTML5: How to define a 
        caption for a figure 
        element?
    </h2>

    <figure>
        <img src=
"https://media.geeksforgeeks.org/wp-content/uploads/geeks-25.png"
        alt="gfglogo" style="width:50%">

        <figcaption>
            GeeksforGeeks Logo
        </figcaption>
    </figure>
</body>

</html>                        
Output: Supported Browsers:
  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Similar Reads