- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <figcaption> Tag
A caption for an image can be added using the <figcaption> element. It is an optional tag that may come before or after the content included within the <figure> tag. Despite the fact that the <figure> element itself may include numerous other elements like <img> or <code>, only one <figcaption> element may be nested within a <figure> tag. The <figcaption> element is used with the <figure> element and can be positioned as either the first or last child of the <figure> element.
Syntax
Following is the syntax of the <figcaption> tag −
<figcaption> figure caption... </figcaption>
Example
Following is an example where we are going to use the <figcaption> tag and add the caption to the image.
<!DOCTYPE html> <html> <body> <figure> <img src="https://www.tutorialspoint.com/cg/images/logo.png" alt="logo" style="width:50%"> <figcaption> Tutorialspoint Logo </figcaption> </figure> </body> </html>
When we execute the above code, it will generate an output consisting of an image uploaded along with a caption for the image that has been displayed on the webpage.
Example
Considering another scenario where we are going to use the <figcaption> tag with CSS.
<!DOCTYPE html> <html> <style> figure { border: 4px #D5F5E3 solid; padding: 4px; margin: auto; } figcaption { background-color: #E8DAEF; color: #DE3163; font-style: italic; padding: 2px; text-align: center; } </style> <body> <figure> <img src="https://upload.wikimedia.org/wikipedia/commons/7/70/Mahendra_Singh_Dhoni_January_2016_%28cropped%29.jpg" alt="Trulli" style="width:100%"> <figcaption>MAHENDRASINGH DHONI</figcaption> </figure> </body> </html>
On running the above code, the output window will pop up, consisting of the image with a caption along with a CSS applied that has been displayed on the webpage.
Example
Let’s look into the another example on the usage of the <figcaption> tag.
<!DOCTYPE html> <html> <style> figcaption { background-color: #E8DAEF; color: #DE3163; font-style: italic; padding: 2px; text-align: center; } </style> <body> <figure> <img src="https://www.tutorialspoint.com/cg/images/logo.png" width="400" height="200"> <figcaption>The Best E-Way Learning.!</figcaption> </figure> </body> </html>
When we execute the above code, it will generate an output consisting of an image uploaded to the webpage mentioned with a caption and applied CSS.
To Continue Learning Please Login
Login with Google