HTMLInputElement: width プロパティ

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.

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

widthHTMLInputElement インターフェイスのプロパティで、コントロールの高さを指定します。これは、 <input> 要素の width 属性を反映します。

width プロパティは、 image 型のみに有効です。これは、ピクセル単位で画像ボタンの水平方向の寸法を定義します。このプロパティの値は、レンダリングされたボタンのコンテンツボックスの幅です。CSS ボックスモデルプロパティがこのコントロールのサイズに影響する場合、そちらが優先されます。

width が設定されておらず、CSS がコントロールのサイズに影響しない場合、width は画像の内在サイズとなります。画像が読み込まれなかった場合、値は alt テキストの高さになります。高さが不明な場合は width0 になります。 width が設定されていない場合、CSS は高さに影響を与えず、画像は読み込まれず、 alt の値は空文字列、または src が設定されていません。

数値です。

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

仕様書

Specification
HTML
# dom-input-width

ブラウザーの互換性

関連情報