Home >Web Front-end >HTML Tutorial >What 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>标题元素,占据一行</h4> <ul> <li>ul1 li 标签 元素</li> <li>ul1 li 标签 元素</li> </ul> <ul> <li>ul2 li 标签 元素</li> <li>ul2 li 标签 元素</li> </ul> </body> </html>
Rendering:
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="1.png" style="max-width:90%" / alt="What types of html tag elements are there? Introduction to common tag elements in html" > <img src="1.png" 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: 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!