Table of Contents
How
and
Work Together
Basic Syntax:
Common Use Cases
Key Points to Remember
Home Web Front-end H5 Tutorial What is the figure element and how is it used with figcaption in HTML5?

What is the figure element and how is it used with figcaption in HTML5?

Aug 20, 2025 pm 02:06 PM
html5

The <figure> element in HTML5 is used to mark up self-contained content like images, diagrams, or code snippets that can stand independently within a document. It can be paired with the optional <figcaption> element to provide a caption or title, which may appear as the first or last child inside <figure>. This combination enhances accessibility and SEO by offering a clear, semantic structure. The <figcaption> typically labels or describes the content, such as "Figure 1: Annual sales growth," while the alt attribute in What is the figure element and how is it used with figcaption in HTML5? remains essential for screen readers. Common uses include images with captions, code listings, and quotations. Importantly, <figure> is not limited to images—it applies to any standalone media block. 1. Use <figure> for self-contained content. 2. Optionally include <figcaption> at the start or end for a caption. 3. Maintain accessibility with proper alt text and semantic structure. 4. Apply to images, code, quotes, or illustrations. 5. Ensure content remains meaningful even when moved. This approach improves both document organization and user experience.

What is the figure element and how is it used with figcaption in HTML5?

The <figure></figure> element in HTML5 is used to mark up self-contained content, such as images, diagrams, photos, code snippets, or illustrations, that can be referenced as a single unit within a document. It's especially useful because it allows the content to be moved around in a document (like in a sidebar or appendix) without affecting the main flow.

What is the figure element and how is it used with figcaption in HTML5?

One of the key features of <figure></figure> is that it can be paired with the <figcaption></figcaption> element to provide a caption or title for the content inside the figure.

How <figure></figure> and <figcaption></figcaption> Work Together

The <figcaption></figcaption> element is optional but recommended when you want to add a descriptive caption. It can be placed as the first or last child inside the <figure></figure> element. If present, it gives a title or explanation for the figure content.

What is the figure element and how is it used with figcaption in HTML5?

Basic Syntax:

<figure>
  <img src="/static/imghw/default1.png"  data-src="chart.png"  class="lazy" alt="Sales growth chart">
  <figcaption>Figure 1: Annual sales growth from 2020 to 2023.</figcaption>
</figure>

In this example:

  • The <figure> wraps the image and its caption.
  • The <figcaption> clearly labels the image as "Figure 1" and describes what it shows.
  • The alt attribute in the <img src="/static/imghw/default1.png" data-src="https://img.php.cn/upload/article/000/000/000/175566998882086.jpeg" class="lazy" alt="What is the figure element and how is it used with figcaption in HTML5?" > tag remains important for accessibility, describing the image for screen readers.

Common Use Cases

  • Images with captions: The most common use.
  • Code snippets:
    <figure>
      <pre class="brush:php;toolbar:false"><code>function hello() {
    console.log("Hello, world!");
    }</code>
    <figcaption>Listing 1: A simple JavaScript function.
  • Quotations:
    <figure>
      <blockquote cite="https://example.com/book">
        It was the best of times, it was the worst of times...
      </blockquote>
      <figcaption>— Charles Dickens, <cite>A Tale of Two Cities</cite></figcaption>
    </figure>

    Key Points to Remember

    • The <figure></figure> element is not just for images — it’s for any standalone media or content block.
    • It’s semantically independent, meaning it makes sense even if moved away from surrounding text.
    • <figcaption></figcaption> can appear at the top or bottom of the <figure></figure> — though bottom is more common.
    • Using these elements improves accessibility and SEO by providing clearer document structure.

    Basically, <figure></figure> and <figcaption></figcaption> help make your content more meaningful and organized, both for browsers and users.

    What is the figure element and how is it used with figcaption in HTML5?

    The above is the detailed content of What is the figure element and how is it used with figcaption in HTML5?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1598
276
What is the aside element for in HTML5? What is the aside element for in HTML5? Aug 12, 2025 pm 04:37 PM

Theelementshouldbeusedforcontenttangentiallyrelatedtothemaincontent,suchassidebars,pullquotes,definitions,advertisements,orrelatedlinks;2.Itcanbeplacedinsideoroutsideanarticledependingoncontext;3.ItisasemanticelementthatenhancesaccessibilityandSEObyp

How to create a simple HTML5 webpage How to create a simple HTML5 webpage Aug 12, 2025 am 11:51 AM

To create a simple HTML5 web page, you need to first use the declaration document type, and then build a basic structure containing, and, which sets the character encoding, viewport and title, add visible content such as title, paragraph, link, pictures and lists. Save it as a .html file and open it directly in the browser for viewing, without server support. This is the basis of a complete and effective HTML5 page.

What is the draggable attribute in HTML5 What is the draggable attribute in HTML5 Aug 12, 2025 am 09:50 AM

ThedraggableattributeinHTML5specifieswhetheranelementcanbedragged,withvalues"true","false",oranemptystring(sameas"true").2.Settingdraggable="true"enablesdrag-and-dropforanyelement,butJavaScripteventlistenerslik

How do you use the autofocus attribute in HTML5? How do you use the autofocus attribute in HTML5? Aug 14, 2025 pm 06:47 PM

Theautofocusattributeautomaticallyfocusesaformelementwhenapageloads.2.Itisabooleanattribute,sonovalueisneeded—justincludeautofocusinthetag.3.Onlyoneelementperpageshoulduseittoavoidunpredictablebehavior.4.Itworksoninput,textarea,select,andbuttonelemen

How to create a custom checkbox with HTML5 How to create a custom checkbox with HTML5 Aug 16, 2025 am 07:05 AM

To create a custom checkbox, you must first use an HTML structure with label to ensure accessibility; 2. Hide the default checkbox through CSS but retain its functionality; 3. Use pseudo-elements and pseudo-classes to draw the selected state on the custom .checkmark elements; 4. Add hover, focus and select styles to enhance interactive feedback; 5. Keep native inputs present to support keyboard navigation and screen readers, and ultimately achieve beautiful and accessible custom checkboxes.

How to use the nav tag for navigation links in HTML5 How to use the nav tag for navigation links in HTML5 Aug 15, 2025 am 05:55 AM

ThetaginHTML5isusedtodefineasectionofmajornavigationlinks,providingsemanticstructureandimprovingaccessibilityandSEO;itshouldwrapprimarynavigationelementslikemenusortablesofcontents,noteverylinkonapage,andcanbeenhancedwithARIAlabelssuchasaria-label=&q

What is a definition list in HTML5? What is a definition list in HTML5? Aug 20, 2025 pm 02:01 PM

AdefinitionlistinHTML5iscreatedusingtheelementtogroupterms()withtheirdefinitions(),allowingmultipletermstoshareadefinitionoratermtohavemultipledefinitions,makingitidealforFAQs,glossaries,metadata,andcontactdetailswhileimprovingaccessibilityandSEOthro

How to defer non-critical CSS in an HTML5 page? How to defer non-critical CSS in an HTML5 page? Aug 12, 2025 am 12:15 AM

To effectively improve page loading performance, you need to inline the critical CSS first and load the non-critical CSS asynchronously; 1. Use tools or manually identify the critical CSS and inline it to; 2. Use rel="preload" to combine onload, JavaScript dynamic loading or requestIdleCallback asynchronously; 3. Use media attributes to delay loading of conditional styles such as print or topics; 4. Merge and compress non-critical CSS to reduce requests; you can use the media="print" technique to achieve JavaScript-free asynchronous loading, thereby significantly optimizing the first-screen rendering speed.

See all articles