<p>包不住<div>是强制的 w3c 标准?还是约定成俗的规范?

lisisi:发现有些浏览器会把<p>中的<div>吐出来,有些不吐。

mokeyjay:没看懂,举个例子?

codehz:p 的内容必须是 flow content ( https://html.spec.whatwg.org/#flow-content
而 div 是 Palpable content ( https://html.spec.whatwg.org/#palpable-content
所以 p 里面不能放 div,
至于为什么 div 会被吐出来,就是因为根据 https://html.spec.whatwg.org/#concept-element-tag-omission 规则,元素结束标签在一些情况可以省略,而多余的结束标签会被忽略
p 的结束标签可以省略
https://html.spec.whatwg.org/#the-p-element

Tag omission in text/html:
A p element's end tag can be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.

Java中的<<或>>>是什么意思? - java

This question already has answers here: Closed 7 years ago. Possible Duplicate: What does >> and >>> mean in Java?我在一些Java代码中遇到了一些陌生的符号,尽管代码可以正确编译和运行,但对于括号在此代码中的作用却感…

菱形运算符<>是否等于<?> - java

我在util.TreeSet类中发现,其中一个构造函数正在使用具有空泛型类型的新TreeMap调用另一个构造函数。 public TreeSet(Comparator<? super E> comparator) { this(new TreeMap<>(comparator)); } new TreeMap<>是什么意思…

如何使整个<div>可选? - javascript

我看过几篇有关使整个div可点击的文章,但我希望使其成为可选择的。我所拥有的是一个php while循环,该循环显示基于用户进入mySQL数据库的表。该代码如下所示: <div class='tracksub'> <div class='headname'><div class='…

声纳测试用例失败 - java

我正在尝试为我的项目之一获得声纳报告。我已经运行mvn clean installRunning blah.blah.BlahTest1 Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec Running blah.blah.BlahTest2 Tests run…

休眠映射<键,设置<值>> - java

我有以下表格:@Entity @Table(name = "events") Event --id --name @Entity @Table(name = "state") State --id --name @Entity @Table(name = "action") Action --id …