search
HomeWeb Front-endHTML TutorialWhat types of html tag elements are there? Introduction to common tag elements in html

The content of this article is to introduce the types of html tag elements, so that everyone can understand what are the commonly used tag elements in html? It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

First of all, let’s understand what types of html tag elements can be divided into?

Tag elements in HTML are generally divided into three different types: block elements, inline elements, and inline block elements.

Let’s introduce the characteristics and uses of these three types of elements in detail, and let everyone know what are the commonly used block elements and inline elements?

Block elements

Features:

1. Each block occupies one row The elements will start again from a new line and be arranged from top to bottom

2. You can directly control the width, height and related css properties of the box model (element's height, width, line height and top and bottom margins All can be set)

3. When the width is not set, the width of the block-level element is the width of the content of its parent element

4. When the height is not set, the width of the block-level element is the width of the content of the parent element. The height of a high-level element is the height of its own content. Because of its own characteristics, we usually use block elements to build large layouts (large structures).

Commonly used block elements:

1. Ordinary elements

div (commonly used block containers and the main tags of CSS layout), p (Paragraph), hr (horizontal separator), table (table), form (interactive form)

2, title elements:

h1 (headline), h2 (subtitle), h3 (Third-level heading), h4 (fourth-level heading), h5 (fifth-level heading), h6 (sixth-level heading)

3, list element

menu (menu list), ol ( Ordered list), ul (unordered list), li (list item), dl (define list), dt (define term), dd (define description)

Let’s take a look at these blocks through simple code Shape element

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>块状元素</title>
		<style>
			div{
				background-color: palegoldenrod;
			}
			p{
				background-color:paleturquoise ;
			}
			h4{
				background-color:papayawhip;
			}
			ul{
				background-color: peru;
			}
		</style>
	</head>
	<body>
		<div>div标签元素,占据一行</div>
		<p>p标签元素,占据一行</p>
		<h4 id="标题元素-占据一行">标题元素,占据一行</h4>
		<ul>
			<li>ul1 li 标签 元素</li>
			<li>ul1 li 标签 元素</li>
		</ul>
		<ul>
			<li>ul2 li 标签 元素</li>
			<li>ul2 li 标签 元素</li>
		</ul>
	</body>
</html>

Rendering:


What types of html tag elements are there? Introduction to common tag elements in html

##Inline element

Features:

1. Displayed in one line with other inline elements from left to right

2. Width, height and related css attributes of the box model cannot be directly controlled. However, it is possible to directly set the left and right values ​​​​of the inner and outer margins

3. The width and height of inline elements are determined by the size of their own content (text, pictures, etc.)

4. Inline elements It can only accommodate text or other inline elements (please note here, do not nest block-level elements in inline elements)

Because of its own characteristics, we usually use inline elements to carry text , Construction of small icons (small structures).

Commonly used inline elements:

1. Common element tags

span (commonly used inline containers, defining in-text blocks), a ( Anchor point, link), img (introducing an image), br (forced line break), sub (subscript), sup (superscript)

2. Text modification tag

b (add bold), strong (bold emphasis), i (italic), em (italic emphasis), big (large font text), small (small font text), s (underline (not recommended)), strike ( (underline), del (text that has been deleted in the document), u (underline)

3. Label elements used in the form

textarea (multi-line text input box), input (Input box), select (drop-down list), label input (element definition label (mark))

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>行内元素</title>
		<style>
			span{
				background-color: palegoldenrod;
			}
			p{
				background-color:paleturquoise ;
			}
		</style>
	</head>
	<body>
		<span>span标签元素1</span>
		<span>span标签元素2</span>
		<img  src="/static/imghwm/default1.png"  data-src="1.png"  class="lazy"      style="max-width:90%" / alt="What types of html tag elements are there? Introduction to common tag elements in html" >
		<img  src="/static/imghwm/default1.png"  data-src="1.png"  class="lazy"      style="max-width:90%" / alt="What types of html tag elements are there? Introduction to common tag elements in html" >
		<p>换一行看看文字效果,我是一段测试代码,<b>被b标签加粗</b>。我是一段测试代码,<i>被i标签变成斜体</i>。</p>
</html>

Rendering:

What types of html tag elements are there? Introduction to common tag elements in html

Inline block elements

Features:

1. They are on the same line as other elements and will not wrap automatically. The default arrangement is from left to right;

2. The height, width, line height, top and bottom margins of the element can be set.

Inline block elements combine the characteristics of inline elements and block elements, but each has its own trade-offs. Therefore, inline block elements are used more often due to their characteristics in daily use, and are useful in many aspects.

Summary: The above are the three types of html tag elements introduced in this article, namely: block elements, inline elements, inline block elements; and an introduction to commonly used block elements and inline elements. Each type of label has its own characteristics. You can try it yourself to see how different labels are used, deepen your understanding, and use different labels in different situations as needed. I hope it will be helpful to everyone's learning. For more related tutorials, please visit: HTML video tutorial, Html5 video tutorial, bootstrap video tutorial!

The above is the detailed content of What types of html tag elements are there? Introduction to common tag elements in html. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

See all articles

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

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version