为什么MDN文档声明所有元素的初始显示值为内联? [英] Why do the MDN docs state that the initial display value for all elements is inline?
问题描述
显然不是这种情况,因为每个元素都可以具有自己的默认值。
请参见此处:
匹配项 MDN文档。
是的,display的初始值为 inline
下面的行(在您的问题中)说它可以对所有元素应用 display
属性,这是正确的,并且不会启动所有元素 h内联,因为如果您阅读MDN文档,则会看到以下内容:
display CSS属性指定用于$ b的呈现框的类型$ b个元素。 在HTML中,默认的
display
属性值取自HTML规范中描述的
行为或来自
浏览器/用户默认值样式表。 XML的默认值为内联
,
包括SVG
(强调是我的)
这行是什么意思是任何浏览器/用户代理都可以自由设置元素的初始值,因为他们认为更好。
NB 请记住,按初始值表示本身使用 initial
值,所以无论何时根据上述说明,将 display:initial
设置为 display:inline
。
This is clearly not the case as each element can have it's own default.
See here:
https://developer.mozilla.org/en-US/docs/Web/CSS/display
Initial value: inline
Applies to: all elements
And of course contradicting documentation which seems more correct in this case.
https://www.w3schools.com/css/css_display_visibility.asp
Is there something I'm missing here?
It seems to clearly state that "all elements" have "initial value" set to inline.
First of all w3schools isn't the official Documentation, W3C is!
TL:DR: You are confusing things -- The initial value of the property which is inline
and to which elements the property applies (no matter the value it has)
They are not related.
Here is the official Documentation about it
Which match MDN Docs.
And yes the initial value of display is inline
the line below (in your question) says it can apply display
property to all elements, which is true and not starting "all elements" with inline, because if you read the MDN Docs you see this:
The display CSS property specifies the type of rendering box used for an element. In HTML, default
display
property values are taken from behaviors described in the HTML specifications or from the browser/user default stylesheet. The default value in XML isinline
, includingSVG
elements.
(Emphasizes is mine)
And what that line means is any browser/user-agent are free to set the initial value of the element as they think it is better.
N.B. Remember that by initial value means using initial
value itself, so whenever you set display:initial
it will became display:inline
as per the Documentation above states.
这篇关于为什么MDN文档声明所有元素的初始显示值为内联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!