[英]What type of element *is* an `<li>`?
So I'm working on a script to check for valid HTML structure when I noticed something a little odd... 所以我正在研究一个脚本来检查有效的HTML结构,当我发现有些奇怪的东西时......
<li>
does not seem to be listed as a block or inline element. <li>
似乎没有被列为块或内联元素。 Not W3C, not Moz Docs , or even w3.org . 不是W3C,不是Moz Docs ,甚至不是w3.org 。
The same goes for <dt>
and <dd>
, they just disappear into limbo and give no definitive element type. 对于
<dt>
和<dd>
,它们只是消失在边缘并且没有给出明确的元素类型。
So my question is: What is an <li>
tag? 所以我的问题是: 什么是
<li>
标签? Block, inline, both ? 块,内联, 两者 ?
While we're at it: What is allowed inside of one of these ambiguous tags? 虽然我们正处于这样的境界 :其中一个模糊标签内部允许什么?
The confusion probably arises because the terms "block" and "inline" have been applied to various different things. 可能出现混淆,因为术语“阻止”和“内联”已经应用于各种不同的事物。
Collections of elements in the HTML DTDs HTML DTD中的元素集合
li
falls into neither group because it is only allowed as a child element of ul
and ol
rather then the many places that %block
and %inline
content is allowed. li
既不属于小组也不属于小组,因为它只允许作为ul
和ol
的子元素,而不是允许%block
和%inline
内容的许多地方。
CSS display properties CSS显示属性
As well as elements which have those values for that property by default. 以及默认情况下具有该属性值的元素。
li
elements have been display: list-item
since CSS 1. li
元素已经display: list-item
自CSS 1起。
Elements which trigger line breaks (and those which do not) 触发换行符的元素(以及不换行的元素)
These are very broad terms that aren't really useful in a technical sense. 这些是非常广泛的术语,在技术意义上并不真正有用。
HTML 5 has dropped the terms for the purposes of describing elements, and you should too. 为了描述元素,HTML 5已经删除了这些术语,你也应该这样做。
What is allowed inside of one of these ambiguous tags?
其中一个模糊标签内部允许什么?
See the HTML 5 specification : 请参阅HTML 5规范 :
Content model :
内容模型 :
Flow content.流量内容。
Flow content is defined as: 流内容定义为:
a
abbr
address
area
(if it is a descendant of amap
element)area
(如果它是map
元素的后代)article
aside
audio
b
bdi
bdo
blockquote
br
button
canvas
cite
code
data
datalist
del
details
dfn
dialog
div
dl
em
embed
fieldset
figure
footer
form
h1
h2
h3
h4
h5
h6
header
hr
i
iframe
img
input
ins
kbd
keygen
label
main
map
mark
math
meter
nav
noscript
object
ol
output
p
pre
progress
q
ruby
s
samp
script
section
select
small
span
strong
style
(if thescoped
attribute is present)style
(如果存在scoped
属性)sub
sup
svg
table
textarea
time
u
ul
var
video
wbr
text
如果你的意思是css display属性:display:list-item;
<li> tag defines a list item.
The <li> tag is used in ordered lists <ol> or unordered lists <ul>.
Example. 例。
unordered: 无序:
<ul>
<li>paper</li>
<li>pen</li>
<li>sheet</li>
</ul>
ordered: 下令:
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
its result is as shown below 其结果如下所示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.