Home Web Front-end HTML Tutorial Overview and differences between html inline elements and html block-level elements_HTML/Xhtml_Web page production

Overview and differences between html inline elements and html block-level elements_HTML/Xhtml_Web page production

May 16, 2016 pm 04:40 PM
inline elements block-level elements

Block-level element (block) characteristics :
•Always occupy a separate line, which means starting on a new line, and subsequent elements must also be displayed on a new line;
•Width (width) , height, padding and margin can all be controlled;

Inline element (inline) properties :
• and adjacent Inline elements are on the same line;
• Width, height, top/bottom of padding (padding-top/padding-bottom) and top/bottom of margin (margin-top/margin -bottom) cannot be changed, that is, the size of the text or pictures inside;

The main block-level elements are :

Copy code
The code is as follows:

address, blockquote, center, dir, div, dl, fieldset, form, h1, h2, h3, h4, h5, h6, hr, isindex, menu, noframes, noscript, ol, p, pre, table, ul

The main inline elements are :

Copy code
The code is as follows:

a , abbr , acronym , b , bdo , big , br , cite , code , dfn , em , font , i , img , input , kbd , label , q , s , samp , select , small , span , strike , strong , sub , sup ,
textarea , tt , u , var

Mutable elements (whether the element is a block or inline element is determined based on context) :

Copy Code
The code is as follows:

applet, button, del, iframe, ins, map, object, script

CSS Application of medium block-level, inline elements :
Using CSS, we can get rid of the restrictions of HTML tag classification in the above table and freely apply the attributes we need on different tags/elements.

The main CSS styles used are the following three :
•display:block - displayed as block-level elements
•display:inline - displayed as inline elements
•dipslay:inline-block -- Displayed as an inline block element, displayed in parallel and can modify attributes such as width, height, inner and outer margins
We often add display:inline-block to the
    element Style, the originally vertical list can be displayed horizontally.

    Off-topic: I recently compiled some relevant knowledge about the difference between block-level elements and inline elements. I found a lot of related articles on the Internet and found that everyone’s understanding seemed to be wrong. I myself After testing it myself, I found a lot of problems:
    1. The margin-left / margin-right and padding-left / padding-rigtht of inline elements can be controlled, so you can pass These 4 properties control the width of inline elements.
    2. Block-level element tags can also be placed inside inline elements, and the internal block-level element tags will expand the external inline tags, so you can control the height of inline elements by placing block elements (online introduction The only thing is that inline elements can only hold text and other inline elements)
    For example:

    Copy code
    Code As follows:
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1669
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
What is the difference between inline elements and block-level elements? What is the difference between inline elements and block-level elements? Oct 16, 2023 am 09:51 AM

There are five differences between inline elements and block-level elements: "box model", "arrangement", "content display", "relative position" and "default size": 1. Inline elements do not generate independent boxes, width and height Determined by the content, block-level elements will generate an independent rectangular frame, and attributes such as width, height, margins, and padding can be set; 2. Inline elements are arranged horizontally on the same line, while block-level elements will be pressed from top to bottom. Arrange in order; 3. Inline elements cannot contain block-level elements, while block-level elements can contain other block-level elements and inline elements.

What are inline elements and block-level elements? What are inline elements and block-level elements? Aug 17, 2023 am 11:33 AM

Inline elements include div, p, h1-h6, ul, ol, li, table, form, etc.; block-level elements include span, a, img, strong, em, input, label, etc. The characteristics of the two elements: 1. Inline elements will occupy a row, automatically fill the width of the parent container, can set width, height, inner and outer margins and other attributes, and can contain other block-level elements and inline elements; 2. Inline elements will not It will occupy an exclusive line, the width and height are determined by the content, and the inner and outer margins only affect the arrangement of the elements themselves, etc.

The difference between inline elements and block-level elements: an in-depth understanding of element classification in HTML The difference between inline elements and block-level elements: an in-depth understanding of element classification in HTML Dec 23, 2023 am 10:01 AM

The difference between inline elements and block-level elements: In-depth understanding of the classification of elements in HTML In HTML, elements can be divided into two categories: inline elements and block-level elements. Understanding their differences is very important to correctly master the layout and style of HTML. This article will provide an in-depth understanding of the characteristics of inline elements and block-level elements, and provide specific code examples. Inline elements Inline elements are elements that are displayed inline by default in HTML documents. They do not occupy an entire row, but appear closely within a row based on how the document flow is arranged. Common in the industry

What are the inline elements and block-level elements in html? What are the inline elements and block-level elements in html? Oct 16, 2023 am 09:57 AM

Commonly used inline elements and block-level elements in HTML are: 1. Block-level elements include semantics such as <div>, <p>, <ul>, <ol>, <li>, <h1>~<h6>, and <header>. tags; 2. Inline elements include tags such as <span>, <a>, <strong>, <em>, <img>, and <input>.

Common examples of CSS inline and block-level elements: giving you a deeper understanding of them Common examples of CSS inline and block-level elements: giving you a deeper understanding of them Dec 23, 2023 am 11:58 AM

Common examples of CSS inline elements and block-level elements: To give you a deeper understanding of them, specific code examples are needed Introduction: In CSS, inline elements and block-level elements are two element types we often encounter. For web page layout and style design, it is very important to understand the difference and usage of inline elements and block-level elements. This article will introduce inline elements and block-level elements in CSS with specific code examples to help readers understand their characteristics and usage more deeply. 1. Inline elements Inline elements (inlineelem

What are inline and block-level elements? What are inline and block-level elements? Nov 24, 2023 pm 01:57 PM

Inline elements include a, span, strong, b, em, i, label, img, input, select, textarea, button, abbr, cite, code, big, small, sub, sup, etc. Block-level elements include div, p, h1-h6, form, ul, ol, dl, dt, dd, li, table, tr, td, th, hr, blockquote, address, menu, pre, etc.

What is the difference between inline elements and block-level elements? What is the difference between inline elements and block-level elements? Aug 18, 2023 pm 05:02 PM

The differences between inline elements and block-level elements are: 1. Inline elements will not occupy an exclusive line, while block-level elements will occupy an exclusive line; 2. The width of an inline element is determined by its content, while the width of a block-level element defaults to that of its parent element. 100%; 3. The box model of inline elements mainly includes horizontal padding, margins and borders, in each direction.

Introduction and differences between HTML5 inline elements and block-level elements Introduction and differences between HTML5 inline elements and block-level elements Dec 28, 2023 pm 02:57 PM

Introduction and differences between HTML5 inline elements and block-level elements HTML5 is a markup language used to create the structure of web pages. In HTML5, elements are divided into two types: inline elements and block elements. Introduction to inline elements: Inline elements are elements that appear as a line in the document flow. They only take up space for their own content and do not disrupt the overall layout of the page. Inline elements can contain text, other inline elements, or parts of block-level elements

See all articles