且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

img标签中的Div标签

更新时间:2023-12-05 07:55:10

img 元素有一个自我关闭标签,所以你不能给它子元素,并期望它工作。其内容模型定义为来源

The img element has a self closing tag, so you can't give it child elements and expect it to work. Its content model is defined as empty. Source.

我怀疑您指定的任何孩子将不会呈现,因为 img 元素是一个替换元素,如W3C中所述规格。

I suspect any children you specify won't be rendered because an img element is a replaced element, as mentioned in the W3C spec.