Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. HTMLInputElement
  4. width

HTMLInputElement: width property

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⁩.

Thewidth property of theHTMLInputElement interface specifies the width of a control. It reflects the<input> element'swidth attribute.

Thewidth property is valid for theimage type only. It defines the preferred horizontal size of the image button, in pixels. The property value is the width of thecontent-box of the rendered button. CSS box model properties impacting the size of the control take precedence.

If nowidth is set and no CSS width properties impact the control, thewidth will be the intrinsic width of the image. If the image didn't load, the value will be the maximum intrinsic width of thealt text. Thewidth will be0 if the width is not known; if nowidth is set, no CSS dimensions apply, no image loaded, and either the value of thealt is the empty string or nosrc is set.

Value

A number.

Examples

js
const inputElement = document.getElementById("imageButton");console.log(inputElement.width);

Specifications

Specification
HTML
# dom-input-width

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp