use element | SVGUseElement object
Creates a new instance of an object that has been defined with the defs element.
![]() |
DOM Information
Inheritance Hierarchy
Members
The SVGUseElement object has these types of members:
Events
The SVGUseElement object has these events.
| Event | Description |
|---|---|
| onload |
Occurs when the browser has fully parsed the element and all of its descendants. |
Methods
The SVGUseElement object has these methods.
| Method | Description |
|---|---|
| getBBox |
Gets the bounding box, in current user space, of the geometry of all contained graphics elements. |
| getCTM |
Gets the transformation matrix that transforms from the current user units to the viewport coordinate system for the nearestViewportElement object. |
| getScreenCTM |
Gets the transformation matrix from the current user units to the screen coordinate system. |
| getTransformToElement |
Gets the transformation matrix that transforms from the user coordinate system on the current element to the user coordinate system on the specified target element. |
| hasExtension |
Determines if the specified extension is supported. |
Properties
The SVGUseElement object has these properties.
| Property | Description |
|---|---|
|
Gets the animated root of the instance tree of a use element. | |
|
Gets the names of the classes that are assigned to this object. | |
|
Sets or retrieves a reference to the SVG graphical object that will be used as the clipping path. | |
|
Gets a value that indicates whether referenced resources that are not in the current document are required to correctly render a given element. | |
|
Gets a value that represents the farthest ancestor svg element. | |
|
Determines if an element can acquire keyboard focus (that is, receive keyboard events) and be a target for field-to-field navigation actions (such as when a user presses the Tab key). | |
|
Gets or sets the height of an element. | |
|
Gets an | |
|
Gets the root of the instance tree of a use element. | |
|
Sets or retrieves a value that indicates a SVG mask. | |
|
Gets a value that indicates which element established the current viewport. | |
|
Gets the nearest ancestor svg element. | |
|
Sets or retrieves a value that specifies under what circumstances a given graphics element can be the target element for a pointer event in SVG. Starting with IE11, this property also has basic support for HTML elements (see "Remarks" section). | |
|
Gets a white space-delimited list of required language extensions. | |
|
Gets or sets a white space-delimited list of feature strings. | |
|
Gets a style object. | |
|
Gets or sets a comma-separated list of language names. | |
|
Gets the value of a transform attribute. | |
|
Gets the element that established the current viewport. | |
|
Defines the width of an element. | |
|
Gets or sets the x-coordinate value. | |
|
Gets or sets the | |
|
Gets or sets a value that specifies the language that is used in the contents and attribute values of an element. | |
|
Gets or sets a value that indicates whether white space is preserved in character data. | |
|
Gets or sets the y-coordinate value. |
Standards information
- Scalable Vector Graphics: Document Structure, Section 5.11.8
Remarks
Microsoft Edge introduces support for referencing external resources with xlink:href in the use element. For example, you can now reference a shape defined in an external resource using the following example:
<use xlink:href="defs.svg#rect-2"></use>
For more information, see the SVG specification.
Examples
In the following code example, the use element is used to create three instances of a rectangle defined in a defs tag. Copy this sample to a text file and save it with the .html file extension. Run it in Internet Explorer 9 to see three instances of a rectangle.
It should look like this:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<svg>
<defs>
<rect id="myRect" width="50" height="50" />
</defs>
<use x="50" y="50" fill="red" xlink:href="#myRect" />
<use x="75" y="75" fill="green" xlink:href="#myRect" />
<use x="100" y="100" fill="blue" xlink:href="#myRect" />
</svg>
</body>
</html>
See also
