Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. SVG
  3. Reference
  4. Attributes
  5. width

width

Thewidth attribute defines the horizontal length of an element in the user coordinate system.

Elements

You can use this attribute with the SVG elements described in the sections below.

<feBlend>

For<feBlend>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feColorMatrix>

For<feColorMatrix>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feComponentTransfer>

For<feComponentTransfer>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feComposite>

For<feComposite>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feConvolveMatrix>

For<feConvolveMatrix>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feDiffuseLighting>

For<feDiffuseLighting>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feDisplacementMap>

For<feDisplacementMap>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feDropShadow>

For<feDropShadow>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feFlood>

For<feFlood>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feGaussianBlur>

For<feGaussianBlur>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feImage>

For<feImage>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feMerge>

For<feMerge>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feMorphology>

For<feMorphology>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feOffset>

For<feOffset>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feSpecularLighting>

For<feSpecularLighting>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feTile>

For<feTile>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<feTurbulence>

For<feTurbulence>,width defines the horizontal length for the rendering area of the primitive.

Value<length> |<percentage>
Default value100%
AnimatableYes

<filter>

For<filter>,width defines the horizontal length for the rendering area of the filter.

Value<length> |<percentage>
Default value120%
AnimatableYes

<foreignObject>

For<foreignObject>,width defines the horizontal length for the rendering area for the referenced document.

Valueauto |<length> |<percentage>
Default valueauto (treated as0)
AnimatableYes

Note:Starting with SVG2,width is aGeometry Property meaning this attribute can also be used as a CSS property for<foreignObject>.

<image>

For<image>,width defines the horizontal length for the image.

Valueauto |<length> |<percentage>
Default valueauto (treated as the intrinsic width of the image)
AnimatableYes

Note:Starting with SVG2,width is aGeometry Property meaning this attribute can also be used as a CSS property for images.

<mask>

For<mask>,width defines the horizontal length of its area of effect. The exact effect of this attribute is influenced by themaskUnits attribute.

Value<length> |<percentage>
Default value120%
AnimatableYes

<pattern>

For<pattern>,width defines the horizontal length of the tile pattern. The exact effect of this attribute is influenced by thepatternUnits andpatternTransform attributes.

Value<length>
Default value0
AnimatableYes

<rect>

For<rect>,width defines the horizontal length for the rectangle.

Valueauto |<length> |<percentage>
Default valueauto (treated as0)
AnimatableYes

Note:Starting with SVG2,width is aGeometry Property meaning this attribute can also be used as a CSS property for rectangles.

<svg>

For<svg>,width defines the horizontal length for the rendering area of the SVG viewport.

Note:In an HTML document if both theviewBox andwidth attributes are omitted,the svg element will be rendered with a width of300px

Valueauto |<length> |<percentage>
Default valueauto (treated as100%)
AnimatableYes

Note:Starting with SVG2,width is aGeometry Property meaning this attribute can also be used as a CSS property for<svg>.

<use>

For<use>,width defines the horizontal length for the referenced element.

Valueauto |<length> |<percentage>
Default valueauto (treated as0)
AnimatableYes

Note:width has no effect onuse elements, unless the element referenced has aviewBox - i.e., they only have an effect whenuse refers to asvg orsymbol element.

Note:Starting with SVG2,width is aGeometry Property meaning this attribute can also be used as a CSS property for used elements.

Examples

html,body,svg {  height: 100%;}

This example includes three<rect> elements with variedwidth attribute values. The first<rect> has awidth="0" set. SVG elements with a width of0 or less are not rendered.

html
<svg viewBox="0 0 100 300" xmlns="http://www.w3.org/2000/svg">  <!-- With a width of 0 or less, nothing will be rendered -->  <rect    x="0"    y="0"    width="0"    height="90"    fill="red"    stroke-width="5"    stroke="black" />  <rect    x="0"    y="100"    width="60"    height="90"    fill="red"    stroke-width="5"    stroke="black" />  <rect    x="0"    y="200"    width="100%"    height="90"    fill="red"    stroke-width="5"    stroke="black" /></svg>

Specifications

Specification
Filters 1.0
# element-attrdef-filter-width
Filters 1.0
# element-attrdef-filter-primitive-width
CSS Masks
# element-attrdef-mask-width
Scalable Vector Graphics (SVG) 2
# Sizing
Scalable Vector Graphics (SVG) 2
# PatternElementWidthAttribute

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp