0

Setting width and height on inline elements 'does not apply'

However, input and button are inline elements, still I can set their width and height by means of CSS (in pixels).

Can someone explain the above?

1 Answers1

3

Depending on the version of CSS you are looking at, they are either replaced inline elements or they are display: inline-block;. Either way, height and width do apply.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I would say it depends on the browser more than the version of CSS - CSS itself doesn't define which elements are replaced inline elements. It does specify how to calculate the sizes of replaced inlines, but that's as far as it gets. Unless you meant to say "version of HTML" instead... – BoltClock Jan 03 '14 at 09:28
  • CSS defined what a replaced element is, it is just up to a browser to treat elements that match the definition as one. The *or* is in the answer because replaced inline elements got special treatment before `display: inline-block` was added to the specification as a neater way to deal with them. (And, having just poked through old versions of the specs, that was a *long* time ago now, it makes me feel old ;) – Quentin Jan 03 '14 at 09:34
  • Are you referring to CSS1, or the original CSS2 recommendation? – BoltClock Jan 03 '14 at 09:35
  • CSS 2. It took quite a lot of clicking "Previous version of the spec" to find it :) – Quentin Jan 03 '14 at 09:36
  • Ah OK - learned something new. I see that the addition of `inline-block` is documented [here](http://www.w3.org/TR/CSS21/changes.html#q3), although of course it doesn't say when. Now if only there were a "Next version" link so you could have started from http://www.w3.org/TR/1998/REC-CSS2-19980512 and worked your way up... – BoltClock Jan 03 '14 at 09:45