Home > Web Front-end > Front-end Q&A > Is li an inline element?

Is li an inline element?

藏色散人
Release: 2023-01-04 09:37:42
Original
4525 people have browsed it

li is not an inline element, but a block-level element. The characteristics of block-level elements include: 1. Always starts on a new line; 2. Height and line height, as well as margins and padding can be controlled ;3. The default width is 100% of its container; 4. It can accommodate inline elements and other block elements.

Is li an inline element?

Recommended: "css video tutorial"

li is an inline element?

li is not an inline element; both ul and li are block-level elements. Because the height, line height, margins and padding of ul and li tags can be controlled; and they can accommodate inline elements and other block-level elements.

Block element (block element), and its counterpart is inline element (inline element) - also called inline element, are concepts in the HTML specification. Most HTML elements are defined as block-level elements or inline elements. Block-level elements usually start (and end) with a newline when displayed by the browser.

Commonly used block-level elements: div, p, form, ul, li, ol, dl, form, address, fieldset, hr, menu, table

Basics of block elements and inline elements The difference is that block elements generally start on a new line, and adjacent block-level elements will be displayed on different lines. When CSS control is added, this attribute difference between block elements and inline elements no longer becomes a difference.

For example, we can add an attribute such as display:block to the inline element, so that it also has the attribute of starting from a new line every time, that is, it becomes a block element. Similarly, we can add display: to the block element. Attributes like inline allow it to be arranged on one line.

Characteristics of block elements

①Always start on a new line;

②Height, line height, margins and padding are all Controllable;

③The width defaults to 100% of its container, unless a width is set.

④It can accommodate inline elements and other block elements

Characteristics of inline elements

①And other elements are on the same line;

②High , line height, outer margins and inner margins cannot be changed;

③The width is the width of its text or picture and cannot be changed

④Inline elements can only accommodate text or other inline elements element

The above is the detailed content of Is li an inline element?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
li
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template