Bootstrap | figure class with Examples

A figure is used when one needs to display a piece of content, generally images with an optional caption. The figure class in Bootstrap is used to add styling to the default figure elements.

  • The base .figure class is used to indicate a figure element.
  • The .figure-img is used to indicate the image used in the figure element.
  • The .figure-caption may be used to display a caption below the figure.

Example: Using the .figure class with a sample image.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
    <!-- Including Bootstrap CSS -->
    <title>Figures in Bootstrap</title>
</head>
  
<body>
    <div class="container">
        <h1>Figures in Bootstrap</h1>
        <figure class="figure">
            <img class="figure-img" src="https://media.geeksforgeeks.org/wp-content/uploads/sample_image.png" >
        </figure>
</body>
</html>                    

chevron_right


Output:
figure without caption



Example: Using the .figure-caption class to show a caption below the image. This class is used with the <figcaption> tag.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
    <!-- Add Bootstrap CSS -->
      
    <title>Figures in Bootstrap</title>
</head>
  
<body>
    <div class="container">
        <h1>Figures in Bootstrap</h1>
          
        <figure class="figure">
            <img class="figure-img" src= "https://media.geeksforgeeks.org/wp-content/uploads/sample_image.png" >
              
            <figcaption class="figure-caption">
                Caption for the above image.
            </figcaption>
        </figure>
</body>
</html>                    

chevron_right


Output:
figure with caption

Reference: https://getbootstrap.com/docs/4.0/content/figures/



My Personal Notes arrow_drop_up

Technical Writer Lets have an update

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.