How to create a caption for a figure element using HTML5 ?
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.
<!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 = alt = "gfglogo" style = "width:50%" > < figcaption > GeeksforGeeks Logo </ figcaption > </ figure > </ body > </ html > |
Output:
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Please Login to comment...