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.

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
width

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報