Open In App

How to specify self-contained content using HTML ?

The <figure> tag in HTML is used to add self-contained content like illustrations, diagrams, photos or codes listing in a document. It is related to main flow but it can be used in any position of a document and the figure goes with the flow of the document and if remove it then it should not affect the flow of the document. This tag is new in HTML5.

Syntax:



<figure> Image content... </figure>

Attributes: It contains mostly two attributes which are listed below:

Example:






<!DOCTYPE html>
<html>
  
<head>
    <title>
        How to specify self-contained
        content using HTML?
    </title>
  
    <style>
        body {
            text-align: center;
        }
  
        h1 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h1>GeeksforGeeks</h1>
  
    <h2>
        How to specify self-contained
        content using HTML?
    </h2>
  
    <figure>
        <img src=
        alt="Geeks" width="304"
            height="228">
              
        <figcaption>Geeks logo</figcaption>
    </figure>
</body>
  
</html>

Output:

Supported Browsers:


Article Tags :