Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. SVG
  3. Reference
  4. Elements
  5. <foreignObject>

<foreignObject>

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The<foreignObject>SVG element includes elements from a different XML namespace. In the context of a browser, it is most likely (X)HTML.

Usage context

CategoriesGraphics element, Renderable element
Permitted contentAny elements or character data

Attributes

height

The height of the foreignObject.Value type:<length> |<percentage>;Default value:auto;Animatable:yes

width

The width of the foreignObject.Value type:<length> |<percentage>;Default value:auto;Animatable:yes

x

The x coordinate of the foreignObject.Value type:<length> |<percentage>;Default value:0;Animatable:yes

y

The y coordinate of the foreignObject.Value type:<length> |<percentage>;Default value:0;Animatable:yes

Note:Starting with SVG2,x,y,width, andheight areGeometry Properties, meaning those attributes can also be used as CSS properties for that element.

DOM Interface

This element implements theSVGForeignObjectElement interface.

Example

html,body,svg {  height: 100%;}
html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">  <style>    div {      color: white;      font: 18px serif;      height: 100%;      overflow: auto;    }  </style>  <polygon points="5,5 195,10 185,185 10,195" />  <!-- Common use case: embed HTML text into SVG -->  <foreignObject x="20" y="20" width="160" height="160">    <!--      In the context of SVG embedded in an HTML document, the XHTML      namespace could be omitted, but it is mandatory in the      context of an SVG document    -->    <div xmlns="http://www.w3.org/1999/xhtml">      Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed mollis mollis      mi ut ultricies. Nullam magna ipsum, porta vel dui convallis, rutrum      imperdiet eros. Aliquam erat volutpat.    </div>  </foreignObject></svg>

Specifications

Specification
Scalable Vector Graphics (SVG) 2
# ForeignObjectElement

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp