草庐IT

html - 为什么图像使用显示: inline but behaves like an inline-block element

coder 2023-08-10 原文

为什么图片的默认显示样式是inline而不是inline-block?

img 元素的 inline 和 inline-block 之间是否有任何区别,据我所知,它们的行为方式完全相同。

最佳答案

IMG 是一个Inline & Replaced 元素。

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

根据 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.

查看此链接了解更多 http://reference.sitepoint.com/css/replacedelements

关于html - 为什么图像使用显示: inline but behaves like an inline-block element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9928211/

有关html - 为什么图像使用显示: inline but behaves like an inline-block element的更多相关文章

随机推荐