Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does image use display: inline but behaves like an inline-block element

Why is the default display style for image inline instead of inline-block?

Is there any difference between inline and inline-block for img elements, from what I can see it behaves exactly in the same way.

like image 929
jontro Avatar asked Mar 29 '12 15:03

jontro


2 Answers

IMG is an Inline & Replaced element.

A replaced element is any element whose appearance and dimensions are defined by an external resource.

As per W3C

The IMG element has no content; it is usually replaced inline by the image designated by the src attribute, the exception being for left or right-aligned images that are "floated" out of line.

Check this link for more http://reference.sitepoint.com/css/replacedelements

like image 91
sandeep Avatar answered Nov 15 '22 07:11

sandeep


The default browser stylesheets were initially created using CSS1 for HTML3.2, so inline-block was not available or necessary. There's no difference between them for image elements.

References

  • CSS 1 Specification
  • HTML 3.2 Specification
like image 27
Paul Sweatte Avatar answered Nov 15 '22 06:11

Paul Sweatte