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

Analysis and solution of flex layout collapse caused by Chrome 73

Phenomenon There are several nested flex structur...

Vue3 (III) Website Homepage Layout Development

Table of contents 1. Introduction 2. Actual Cases...

MySQL master-slave replication configuration process

Main library configuration 1. Configure mysql vim...

Detailed explanation of the use of the clip-path property in CSS

Use of clip-path polygon The value is composed of...

Comparison of storage engines supported by MySQL database

Table of contents Storage Engine Storage engines ...

A brief analysis of Vue's asynchronous update of DOM

Table of contents The principle of Vue asynchrono...

Detailed tutorial on installing phpMyAdmin on Ubuntu 18.04

We will install phpMyAdmin to work with Apache on...

Understanding and solutions of 1px line in mobile development

Reasons why the 1px line becomes thicker When wor...

HTML+CSS+JavaScript to create a simple tic-tac-toe game

Table of contents Implementing HTML Add CSS Imple...

Linux tutorial on replacing strings using sed command

To replace a string, we need to use the following...

Detailed tutorial on replacing mysql8.0.17 in windows10

This article shares the specific steps of replaci...

Nodejs combined with Socket.IO to realize websocket instant communication

Table of contents Why use websocket Socket.io Ope...