Home Web Front-end HTML Tutorial Basic concepts and usage examples of html inline elements and block-level elements_HTML/Xhtml_Web page production

Basic concepts and usage examples of html inline elements and block-level elements_HTML/Xhtml_Web page production

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

HTML tags are divided into two types, inline elements and block-level elements. First, let’s understand the concepts of inline elements and block-level elements:

Block-level elements: is generally a container for other elements, which can accommodate inline elements and other block-level elements. Block-level elements exclude other elements that are on the same line as them. The width and height can be set ( height) attribute, block-level elements in normal flow will be placed vertically. Common block elements are "div"

Inline elements (inline elements): Inline elements can only accommodate text or other inline elements. They are descendants of block-level elements. They allow other inline elements to be located on the same line as them and cannot be set. Height and width. A common inline element is "a".

According to the concept of block-level elements, we can understand that block-level elements have line breaks before and after them, which is equivalent to adding a
tag before and after the element. We can think of block-level elements as a block or a rectangle, so block-level elements can set the height and width attributes

Example:
css file:

Copy code
The code is as follows:

#div1{
width:200px;
height:200px;
background:#666
}
div2{
width:200px;
height:200px;
background:#F00
}

html file:

Copy code
The code is as follows:


div1
The block-level element excludes other elements located on the same line as it


div2
Block-level elements exclude other elements located on the same line as it


Display effect:

The two div elements are not on the same line

According to the concept of inline elements, we can understand that there are no line breaks before and after inline elements. We can think of an inline element as a line, so it cannot set the height and width attributes.

Block element tag

address - address
blockquote - block quote
center - center alignment
dir - directory list
div - commonly used block level is also the main tag of CSS layout
dl - definition list
fieldset - form control group
form - interactive form
h1 - headline
h2 - subtitle
h3 - level 3 title
h4 - level 4 title
h5 - 5 Level title
h6 - Level 6 title
hr - Horizontal separator line
isindex - input prompt
menu - Menu list
noframes - frames optional content, (for browsers that do not support frames Show this block content
noscript - optional script content (show this content for browsers that do not support script)
ol - sort form
p - paragraph
pre - formatted text
table - table
ul - unsorted list

inline element

a - anchor
abbr - abbreviation
acronym - first word
b - bold (not recommended)
bdo - bidi override
big - big font
br - Line break
cite - quote
code - computer code (required when citing source code)
dfn - define field
em - emphasis
font - font setting (not recommended)
i - italic
img - image
input - input box
kbd - define keyboard text
label - table label
q - short quote
s - underscore
samp - Define sample computer code
select - Item selection
small - Small font text
span - Commonly used inline containers, define blocks within text
strike - Underline
strong - Bold Emphasis
sub - subscript
sup - superscript
textarea - multi-line text input box
tt - define typewriter text
var - define variable

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 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)

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.

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.

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

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.

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>.

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