pub struct Object;Expand description
The <object> element - embeds external resource as an object.
§Purpose
The <object> element represents an external resource, which can be treated as an image,
nested browsing context, or resource to be handled by a plugin. It provides fallback
content for when the object cannot be displayed. More flexible than <embed> with better
fallback support, but modern elements like <video>, <audio>, and <iframe> are often
more appropriate.
§Content Categories
- Flow Content
- Phrasing Content
- Embedded Content
- If with
usemapattribute: Interactive Content - Palpable Content
§Permitted Content Model
- Zero or more
<param>elements - Followed by transparent content (fallback)
§Common Use Cases
- Embedding PDF documents with fallback
- Displaying SVG images with fallback content
- Plugin-based content with degradation path
- Embedding Flash content with alternatives (legacy)
- Nested browsing contexts with fallback options
§Key Attributes
data: URL of the resourcetype: MIME type of the resourcename: Name for form submission or scriptingwidth: Width in CSS pixelsheight: Height in CSS pixelsusemap: Associates with an image mapform: Associates with a form elementtypemustmatch: Type attribute must match resource’s type
§Example
<!-- PDF with fallback link -->
<object data="/documents/report.pdf"
type="application/pdf"
width="800"
height="600">
<p>Your browser doesn't support PDF viewing.
<a href="/documents/report.pdf">Download the PDF</a></p>
</object>
<!-- SVG with fallback image -->
<object data="/images/diagram.svg"
type="image/svg+xml"
width="400"
height="300">
<img src="/images/diagram.png" alt="Diagram">
</object>
<!-- Object with parameters -->
<object data="/media/animation.swf"
type="application/x-shockwave-flash"
width="640"
height="480">
<param name="quality" value="high">
<param name="autoplay" value="false">
<p>Flash content requires the Adobe Flash Player.</p>
</object>
<!-- Nested fallbacks -->
<object data="/video/movie.mp4" type="video/mp4">
<object data="/video/movie.ogv" type="video/ogg">
<p>Your browser doesn't support the video. <a href="/video/movie.mp4">Download</a></p>
</object>
</object>§Accessibility
- Provide meaningful fallback content
- Ensure embedded content is accessible
- Use
aria-labelor descriptive fallback text - Test with assistive technologies
- Consider using semantic alternatives when available
§WHATWG Specification
Trait Implementations§
Source§impl HtmlElement for Object
impl HtmlElement for Object
impl CanContain<Param> for Object
impl<T: FlowContent> CanContain<T> for Object
impl EmbeddedContent for Object
impl FlowContent for Object
impl PalpableContent for Object
impl PhrasingContent for Object
Auto Trait Implementations§
impl Freeze for Object
impl RefUnwindSafe for Object
impl Send for Object
impl Sync for Object
impl Unpin for Object
impl UnwindSafe for Object
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