【问题标题】:Where can I find the documentation for the default display for <input>?我在哪里可以找到 <input> 的默认显示的文档?
【发布时间】:2021-08-24 04:07:06
【问题描述】:

我假设它是内联或阻塞的,但我想在文档中验证它,但在 MDN 上找不到它。

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input

我正在使用类型设置为文本的输入。

【问题讨论】:

  • 它是一个内联元素。
  • 请不要使用 w3schools.com。他们的内容真的过时了!
  • 感谢更新,我正在寻找文档。在我创建了一个小提琴并查看之后,它似乎是内联的,但是文档在哪里?
  • 您应该查找有关每个 HTML 元素的默认显示值的文档。因此,不要寻找 input 元素,而是关注 display 默认值。
  • 根据 web dev 简化的教程,默认情况下每个元素都是 inline-block。重要的是浏览器如何呈现它。因此,在基于 chromium 的浏览器中,输入标签默认是内联的,而 h1 默认是阻塞的。

标签: html css manpage


【解决方案1】:

官方规范规定输入元素显示为 inline-block。

这是默认样式表:

html, address,
blockquote,
body, dd, div,
dl, dt, fieldset, form,
frame, frameset,
h1, h2, h3, h4,
h5, h6, noframes,
ol, p, ul, center,
dir, hr, menu, pre   { display: block; unicode-bidi: embed }
li              { display: list-item }
head            { display: none }
table           { display: table }
tr              { display: table-row }
thead           { display: table-header-group }
tbody           { display: table-row-group }
tfoot           { display: table-footer-group }
col             { display: table-column }
colgroup        { display: table-column-group }
td, th          { display: table-cell }
caption         { display: table-caption }
th              { font-weight: bolder; text-align: center }
caption         { text-align: center }
body            { margin: 8px }
h1              { font-size: 2em; margin: .67em 0 }
h2              { font-size: 1.5em; margin: .75em 0 }
h3              { font-size: 1.17em; margin: .83em 0 }
h4, p,
blockquote, ul,
fieldset, form,
ol, dl, dir,
menu            { margin: 1.12em 0 }
h5              { font-size: .83em; margin: 1.5em 0 }
h6              { font-size: .75em; margin: 1.67em 0 }
h1, h2, h3, h4,
h5, h6, b,
strong          { font-weight: bolder }
blockquote      { margin-left: 40px; margin-right: 40px }
i, cite, em,
var, address    { font-style: italic }
pre, tt, code,
kbd, samp       { font-family: monospace }
pre             { white-space: pre }
button, textarea,
input, select   { display: inline-block }
big             { font-size: 1.17em }
small, sub, sup { font-size: .83em }
sub             { vertical-align: sub }
sup             { vertical-align: super }
table           { border-spacing: 2px; }
thead, tbody,
tfoot           { vertical-align: middle }
td, th, tr      { vertical-align: inherit }
s, strike, del  { text-decoration: line-through }
hr              { border: 1px inset }
ol, ul, dir,
menu, dd        { margin-left: 40px }
ol              { list-style-type: decimal }
ol ul, ul ol,
ul ul, ol ol    { margin-top: 0; margin-bottom: 0 }
u, ins          { text-decoration: underline }
br:before       { content: "\A"; white-space: pre-line }
center          { text-align: center }
:link, :visited { text-decoration: underline }
:focus          { outline: thin dotted invert }

/* Begin bidirectionality settings (do not change) */
BDO[DIR="ltr"]  { direction: ltr; unicode-bidi: bidi-override }
BDO[DIR="rtl"]  { direction: rtl; unicode-bidi: bidi-override }

*[DIR="ltr"]    { direction: ltr; unicode-bidi: embed }
*[DIR="rtl"]    { direction: rtl; unicode-bidi: embed }

@media print {
  h1            { page-break-before: always }
  h1, h2, h3,
  h4, h5, h6    { page-break-after: avoid }
  ul, ol, dl    { page-break-before: avoid }
}

您可以找到所有规格here

【讨论】:

  • 你是怎么找到这个的?你谷歌了什么?它是最新的吗?谢谢!
  • 我正在构建一个浏览器,所以我环顾四周,发现像 w3c、whatwg 这样的组织会为浏览器编写规范。是的,这是最新的,这是所有浏览器都遵循的官方规范。我在答案中附加的链接基本上是 2020 年所有规格的快照,因为 2021 年尚未结束,2021 年还没有结束。顺便说一句,这里是 my browser
  • 该列表绝对不是最新的。例如,main 元素是 display:block,但未在此处列出。
  • @Sujal ...再次感谢...如果有一天我学会了python,我会看看你的代码。
  • 嗨,我查看了最新的部分,答案中的样式表似乎是针对 HTML4 的,但据我对这些规范的了解,旧规范已被取代而不是被覆盖(即本规范可能不包含所有元素,但我认为它的内容是正确的)。我可能是错的(我是这些规范的新手),但我能找到的带有main 元素的最新版本是here。它不是答案中的一个大样式表,而是分成单独的部分。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-09-13
  • 1970-01-01
相关资源
最近更新 更多