Is the tag li a block-level element?

Is the tag li a block-level element?
Why can it set the height, but unlike elements like <h1 />, it feels like it is a "semi-inline" (inline: inline[text]-level) element. HTML 4 describes it this way:

The following elements may also be considered block-level elements since they may contain block-level elements:

  • DD – Definition description
  • DT – Definition term
  • FRAMESET – Frameset
  • LI – List item
  • TBODY – Table body
  • TD – Table data cell
  • TFOOT – Table foot
  • TH – Table header cell
  • THEAD – Table head
  • TR – Table row

This description seems to be saying that <li /> is a "semi-inline" element. Of course, elements like <td /> in this list have also caused me such doubts. Today I took a look at the default CSS of various browsers. The result is this:

Browsers CSS
IE6/IE7 li{display:block; }
IE8+ / Webkit / Firefox / Opera li{display:list-item; }

Here, it is basically clear. In A-Grade browsers other than IE6/7, it is a "semi-inline" element. Speaking of display:list-item; in fact, even though all A-Grade browsers now support it, not many people use it. Why? It's actually useless. In Quirks Mode, PPK says:

display: list-item means that the element is displayed as a list-item, which mainly means that it has a bullet in front of it (like an UL), except in IE 5 on Mac where it gets a number (like an OL). The numbers are buggy: all previous LI's in the page count as one, so this example starts with number 5 (the screenshot was made before I inserted my compatibility-LI's).

Live example:

display: block

display: list-item
display: list-item

Right. Actually, this doesn’t mean much. But it also solved one of my doubts. Share it. If you have such doubts, maybe next time when you encounter a bug or other questions during coding, you will be able to react quickly.

<<:  Seven Principles of a Skilled Designer (1): Font Design

>>:  Mobile terminal adaptation makes px automatically converted to rem

Recommend

MySQL high concurrency method to generate unique order number

Preface After this blog post was published, some ...

How to create a simple column chart using Flex layout in css

The following is a bar chart using Flex layout: H...

Solution to the problem of slow docker pull image speed

Currently, Docker has an official mirror for Chin...

Analyze the duration of TIME_WAIT from the Linux source code

Table of contents 1. Introduction 2. First, let&#...

Summary of twelve methods of Vue value transfer

Table of contents 1. From father to son 2. Son to...

Install mysql5.7.17 using RPM under Linux

The installation method of MySQL5.7 rpm under Lin...

The process of using vxe-table to make editable tables in vue

There is a table in the project that needs to be ...

Why MySQL does not recommend using null columns with default values

The answer you often hear is that using a NULL va...

javascript realizes 10-second countdown for payment

This article shares the specific code of javascri...

Some common advanced SQL statements in MySQL

MySQL Advanced SQL Statements use kgc; create tab...

Vue realizes the whole process of slider drag verification function

Rendering Define the skeleton, write HTML and CSS...

Detailed explanation of various HTTP return status codes

When a request is sent to your server to display ...

MySQL quick recovery solution based on time point

The reason for writing such an article is that on...