pub struct Figure;Expand description
The <figure> element - self-contained content.
§Purpose
The <figure> element represents self-contained content, typically with a caption,
that is referenced as a single unit from the main content. Often used for images,
diagrams, code listings, or other content that can be moved away from the main flow.
§Content Categories
- Flow Content
- Palpable Content
§Permitted Content Model
- Either: one
<figcaption>followed by flow content - Or: flow content followed by one
<figcaption> - Or: flow content only
§Common Use Cases
- Images with captions
- Code examples with descriptions
- Diagrams or illustrations
- Quotations with attributions
- Videos or multimedia with captions
§Key Attributes
- Global attributes only
§Example
<figure>
<img src="chart.png" alt="Sales data chart">
<figcaption>Figure 1: Q4 Sales Performance</figcaption>
</figure>
<figure>
<pre><code>function greet(name) {
return `Hello, ${name}!`;
}</code></pre>
<figcaption>Example: Template literal usage</figcaption>
</figure>§Accessibility
- Screen readers associate caption with content
- Use
<figcaption>for accessible descriptions
§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Figure
impl HtmlElement for Figure
impl<T: FlowContent> CanContain<T> for Figure
impl FlowContent for Figure
impl PalpableContent for Figure
Auto Trait Implementations§
impl Freeze for Figure
impl RefUnwindSafe for Figure
impl Send for Figure
impl Sync for Figure
impl Unpin for Figure
impl UnwindSafe for Figure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more