1

According to CSS docs:

The width CSS property ... applies to all elements but non-replaced inline elements, table rows, and row groups

Input is inline element. So why width property is work with input element?

2
  • 1
    "non-replaced inline elements". Commented Aug 14, 2015 at 16:58
  • 1
    Kinda spells it out right there. Since inputs are replaced inline elements, width applies to them. Commented Aug 14, 2015 at 17:02

1 Answer 1

1

The exception is for non-replaced inline elements. Input is a replaced element.

Replaced element

In CSS, a replaced element is an element whose representation is outside the scope of CSS. These are kind of external objects whose representation is independent of the CSS. Typical replaced elements are <img>, <object>, <video> or form elements like <textarea> and <input>. Some elements, like <audio> or <canvas> are replaced elements only in specific cases. Objects inserted using the CSS content properties are anonymous replaced elements.

CSS handles replaced elements specifically in some cases, like when calculating margins and some auto values.

Note that some replaced elements, but not all, have intrinsic dimensions or a defined baseline, which is used by some CSS properties like vertical-align.

Reference: MDN - Replaced element

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.