HTML common tags


Learning labels is tricky. The focus is to remember the semantics of each label. According to the semantics of tags, giving the most reasonable tags in the right place can make the page structure clearer. This article introduces some common tags of HTMl. For some tags that are not commonly used, those interested can go to the official website to learn

The following is the main content of this article, and the following cases can be used for reference

Common label I

1. title Tag

The titles of different documents are defined and displayed in the browser title bar



Code effect:

2. meta tag

Describes some basic metadata that is not displayed in the browser but parsed by the browser

< meta / > usage example:

<!--1,Declaration code-->
<meta charset="utf-8">
<!--2,Refresh current page-->
<meta http-equiv="refresh" content="1">

3. link tag

Defines the relationship between documents and external resources. Typically used to link style sheets


 <link rel="stylesheet" href="style.css">

4. script tag

Used to load script files or write script code


<!--1,Load script file-->
 <script src=""></script>
 <!--Write script code-->
    var username = this.getQueryString("username");

5. style label

Defines the style reference address of the HTML document, or directly adds a style to render the HTML document


        *b {
            margin: 0;
            padding: 0;

6. Wrap label

If you want to force a line break for a paragraph of text, you need to use a line break label < br / >

Note: the abbreviation of the word break means to break and wrap

Label semantics: forced line wrapping


1. < br / > is a single label

2. < br / > labels simply start a new line. Unlike paragraphs, some vertical spaces will be inserted between paragraphs


<p>This is a<br> Paragraph text</p>

Code effect:

7. Split line

If you need to add a split line to the page, use the split line label < HR / >

Note: the word hr means horizontal separator


< HR / > is a single label



Code effect:

8. Notes

Comments in HTML with <-- Start with -- > and end with -- >

Shortcut keys: Ctrl+/


<!--HTML Notes for-->

9. Text formatting label

In web pages, you sometimes need to set the effect of bold, italic or underline for text. At this time, you need to format the text tag in HTML to display the text in a special way

Tag semantics: highlight the importance, which is more important than ordinary words

Common formatting labels:

Bold< strong > < / strong > or < b ></b>It is more recommended to use < strong > tags with stronger semantics
tilt<em>< / EM > or < I > < / I >It is more recommended to use < EM > tags with stronger semantics
Delete line< del > < / del > or < s > < / s >It is more recommended to use the < del > tag, which has stronger semantics
Underline< ins > < / INS > or < U > < / u >It is more recommended to use < ins > tags with stronger semantics
superscript <sup></sup>


   I am <strong>Ma Dongmei</strong> Now I <b>Very fat</b> <br>

    As soon as class is over <em> helter-skelter</em> One more <i>The label is also tilted</i> <br>
    No <del>996</del> No <s>995</s> present price<strong> 007</strong>Take home
    heavenly <ins>Star River</ins> Turn, <u>The curtain of the world hangs</u> <br>

Code effect:

10. Special characters

In HTMl pages, some special symbols are inconvenient to use directly. At this time, we can use the following characters instead.

Special charactersdescribeCharacter code
nonbreaking space &nbsp;
Full space (1em=16px)&emsp;
Half width space&ensp;
>Greater than sign&gt;
<Less than sign&lt;
&Sum number&amp;
''Quotation marks&quot;
®Registered trademark&reg;

Note: except for space, greater than sign and less than sign, the rest are rarely used

Common label II

1. Title label h1~h6

In order to make web pages more semantic, we often use title tags in web pages. HTML provides six levels of web page titles, namely h1~h6


The abbreviation of the word head, which means head and title

Label semantics:

Used as a title and diminishing in importance


1. The text with a title will become bold and the font size will increase in turn.

2. One title occupies one line


<h1>There are six levels of titles,</h1>
<h2>The text is bold on one line.</h2>
<h3>From big to small,</h3>
<h4>From heavy to light.</h4>
<h5>After the grammar specification is written,</h5>
<h6>See for specific effects.</h6>

Code effect:

Comparison between title label and size attribute


<font size="7">This is font size 7</font>
    <h1>This is a size one font</h1>
    <font size="6">This is font size 6</font>
    <h2>This is font size two</h2>
    <font size="5">This is font size 5</font>
    <h3>This is a three point font</h3>
    <font size="4">This is font size 4</font>
    <h4>This is a four point font</h4>
    <font size="3">This is font size 3</font>
    <h5>This is a five point font</h5>
    <font size="2">This is font size 2</font>
    <h6>This is a six point font</h6>
    <font size="1">This is font size 1</font>

Code effect:

2. Paragraph label

In the web page, to display the text in an organized way, you need to display these words in segments. In HTML tags, the p tag is used to define paragraphs. It can divide the whole web page into several paragraphs


An abbreviation for the word paragraph

Label semantics:

Split an HTML document into paragraphs


1. Text wraps automatically in a paragraph according to the size of the browser window.

2. There is a gap between paragraphs


 <p>This is a paragraph</p>
    <a href="#">
      <img src="" alt="Loading...">

Code effect:

3. div tag and span tag

< div > and < span > have no semantics. They are just a box for content


The abbreviation of the word division is div, which means division and partition;
Span means span and span;


1. Div tags are used for layout. Only one div large box can be placed in a row

2. Span tags are used for layout. There can be multiple span small boxes on a line


  <div>I am a div label. div It is a container, which can be understood as a box. Features: exclusive line</div>
    <div>div Yeah, me too</div>

    <span>1:I am a span label.
        This is also a container, which can be understood as a box containing content.
        Features, not exclusive line
        How long is he. I have as much content as I have
        2:span:Me too
        span Not exclusive. If a lot of content reaches the end of the browser, it will wrap automatically


Code effect:

3. Picture labels and paths

In HTML tags, img tags are used to define images in HTML pages.


Abbreviation for the word image, meaning image

Required attributes:

"src" is a required attribute of the label, which specifies the path and file name of the image file

Other properties:

attributeAttribute valueexplain
alttextReplace the text when the image cannot be displayed
titletextPrompt text, mouse over the image to display the text
widthpixelSets the width of the image
heightpixelSets the height of the image
borderpixelSets the border thickness of the image


1. Only one of the width/height attributes of the image is set, and the image will be reduced or enlarged to the same scale

2. Image tags can have multiple attributes and must be written after the tag name of the start tag

3. There is no order between attributes. Tag names and attributes, attributes and attributes are separated by spaces

4. The attribute takes the format of key value pair, that is, the format of key="value"


There will be a lot of pictures on the page. Usually, we will create a new folder to store these image files. At this time, when looking for images, we need to use the "path" method to specify the location of the graphics file

Paths can be divided into:

1. Relative path: the directory path established based on the location of the reference file. Simply put, the position of the picture relative to the HTML page

Same pathImage files are at the same level as HTML files, such as < img SRC = "snowflake. JPG" >
Next level path/Or/The image file is located one level below the HTML file, such as < img SRC = "images / snowflake. JPG" >
Upper level path.../The image file is located one level above the HTML file, such as < img SRC = ".. / images / snowflake. JPG" >

Note: the relative path starts from the file where the code is located to find the target file

2. Absolute path:

It refers to the absolute location under the directory and directly reaches the target location. It is usually the path starting from the drive letter, such as "D:\web\img\logo.png";

Or a complete network address, such as“ ”;

4. Hyperlink label

In HTML tags, a tag is used to define hyperlinks, which are used to link from one page to another

1. Syntax format of links

<a href="Jump target" target="Pop up method of target window">Text or image</a>


Abbreviation for anchor, which means anchor

2. Link properties

attributeAttribute valueexplain
hrefurlUsed to specify the URL address of the link target, (required attribute) it has the function of hyperlink only when the href attribute is applied to the tag
target_ self (default)_ blank (open in new window)
relSpecifies the relationship between the current document and the target URL
typeSpecifies the MIME type of the destination URL

3. Classification of links

  • External links

    For example:

    <a href=" Com "> Baidu</a>
  • internal link

    For the interconnection between the internal pages of the website, you can directly link the internal page name

    For example:

    <a href="index.html">home page</a>
  • Empty link

    If the link target is not determined at that time

    <a href="#"> Home Page</a>
    <a href="javascript;">home page</a>
  • Download link

    If the address in href is a file or compressed package, the file will be downloaded

    <a href="">Click download</a>
  • Page element link

    Hyperlinks can be added to various web page elements in the web page, such as text, image, table, audio, video, etc

    • Create picture link

      <a href="#">
            <img  border="10" src="xx.jpg" alt="" width="" height="" title="">
    • Borderless picture links

      <a href="#">
              <img  border="0" src="xx.jpg" alt="" width="" height="" title="">
    • Link to picture

      <a href="xx.jpj">Connect to picture</a>
  • Anchor link


    1. Insert id in the document and set anchor point;

    2. Create a link in HTML document (or other HTML documents) to jump to the location with anchor points;

    <p id="tips"> Useful tips</p>
    <a href="#Tips "> access the useful tips section</a>
    <a href="xx.html/#Tips "> access the useful tips in the xx.html document</a>

5. Table label

1. Main functions of tables

Table is mainly used to display and display data, because it can make the data display very regular and readable.

2. Table label basic syntax

    <caption>Table title</caption>
        <th>Header cell 1</th>
        <th>Header cell 2</th>
        <td>Normal cell 1</td>
        <td>Normal cell 2</td>
        <td>Normal cell 3</td>
        <td>Normal cell 4</td>
  • Table base label:

    1. < Table > < / Table > is used to define the label of the table

    2. The < tr > < / TR > tag is used to define the rows of the table and must be nested in the < Table > tag

    3. The < th > < / th > tag is used to define the first row or column of the table. The text content in the header cell is bold and centered

    4. The < td > < / td > label is used to define cells in the table and must be nested in the label

    5. The < caption > < / caption > label is used to define the title of the table and will be displayed above the table

  • Table structure label:

    1. Label - head of table

    2. Label - table body

    3. Label - bottom of table

3. Table properties

We don't often use these attributes of table labels in development. We will set them later through css

Attribute nameAttribute valuedescribe
alignleft | center | rightSpecifies the alignment of the table with respect to the surrounding elements
border1 or ''Specifies whether the table cell has a border. The default is "", which means there is no border
cellpaddingPixel valueSpecifies the space between the edge of the cell and its content. The default is 1 pixel
cellspacingPixel valueSpecifies the space between cells. The default is 2 pixels
widthPixel value or percentageSpecify the width of the table

4. Merge cells

  • Cross row merge: rowspan = "number of merged cells"

  • Cross column merge: colspan = "number of merged cells"


   <table border="1" width="500" height="500" align="center" cellpadding="0" cellspacing="0">
       <!-- first line -->
            <!-- The second column is merged across one column, and the three columns in the first row are merged-->
            <td colspan="2"></td>
            <!-- <td></td> -->
                <td rowspan="2"></td>
            <!-- The merged cells must be deleted, or they will continue to occupy a position and squeeze out other cells -->
                <!-- <td></td> -->

Code effect:

6. List label

  • Unordered list

The < UL > tag represents an unordered list of items in an HTML page. Generally, the list items are presented as bullets, and the list items are defined by the < li > tag

Basic syntax:

    <li>List item 1</li>
    <li>List item 2</li>
    <li>List item 3</li>


1. There is no order between the lists of unordered lists, which are parallel;

2. Only < li > can be nested in < UL >, and it is not allowed to directly enter other labels or text in < UL > labels;

3. < li > is equivalent to a container, which can hold all elements;

4. The unordered list will have its own style attribute. In actual use, we will use css to set it


        <li>Web front end</li>
        <li>UI Design</li>

Code effect:

  • Ordered list

An ordered list is an ordered list, and each list will be arranged and defined in a certain order

In HTML tags, < ol > tags are used to define a sequence table, list sorting is displayed in numbers, and < li > tags are used to define list items

Basic syntax:

    <li>List item 1</li>
    <li>List item 2</li>
    <li>List item 3</li>


1. Only < li > can be nested in < ol >, and it is not allowed to directly enter other labels or text in < ol > labels;

2. < li > is equivalent to a container, which can hold all elements;

3. The unordered list will have its own style attribute. In actual use, we will use css to set it


 <h2>Fan list</h2>
        <li>Andy Lau 10000</li>
        <li>Liu Ruoying 1000</li>
        <li>Dirieba 100</li>
        <li> Gulinaza 10 </li>
        <li>Marzaha 1</li>

Code effect:

  • Custom list

Custom lists are usually used to explain and describe terms. The list that defines the list does not have any bullets

In HTML tags, < DL > tag is used to define the description list (or definition list), which will be used together with < DT > (define item / name) and < DD > (describe each item / name)

Basic syntax:

    <dt>Noun 1</dt>
    <dd>Noun 1 interpretation 1</dd>
    <dd>Noun 2 interpretation 2</dd>


1. < DL > can only contain < DT > and < DD >

2. There is no limit to the number of < DT > and < DD >


 <!-- Custom list dl  dt  dd -->
        <dt>Help center</dt>
            <dd>Account management</dd>
            <dd>Shopping Directory</dd>
            <dd>Order operation</dd>

        <dt>Service support</dt>
            <dd>Service 1</dd>
            <dd>Service 2</dd>
            <dd>Service 3</dd>

Code effect:

7. Form label

  • Purpose of using the form

To collect user information

  • Form composition

In HTML, a complete form is usually composed of form fields, form controls and prompt information

  • Form field

The area containing the form. In HTML tags, tags are used to define form fields to realize the collection and transmission of user information;

< form > will submit the form element information within its scope to the server

<formb action="url address" method="Submission method" name="Form field name">
    Various form element controls

Common attributes:

attributeAttribute valueeffect
actionURLSpecifies the URL address of the server program that receives and processes form data
methodget/postSet the form data submission method
namenameSpecify the name of the form to distinguish multiple form fields in the same page
  • input form control

    1. Input input form element

    < input > is used to collect user information


    The < input > tag is a single tag, and there can be multiple < input > small boxes on a line

    The < input > tag contains a type attribute. According to different type attribute values, the input field has many forms:

Attribute valuedescribe
buttonDefine clickable buttons
checkboxcheck box
fileInput field and browse button for file upload
hiddenDefine hidden input fields
imageSubmit button in image form
passwordPassword field. The characters in this field are masked
radioradio button
resetReset button
submitSubmit button
textSingle line input field, default width 20 characters

Other common attributes:

attributeAttribute valuedescribe
namecustomThe name of the input element
valuecustomThe value of the input element
checkedcheckedSpecifies that the input element should be selected when it is first loaded
maxlengthpositive integerSpecifies the maximum length of characters in the input field


1. name and value are attribute values of each form element, which are mainly used by background personnel

2. Name is the name of the form element. Radio buttons must have the same name value

3. The checked attribute is mainly used for radio buttons and check buttons

4. maxlength is the maximum number of characters that users can enter in form elements, which is generally less used

  • input form element application

1. Some form elements display several text by default as soon as they are opened


user name:<input type="text" value="enter one user name">

Code effect:

2. Distinguish between different forms


user name:<input type="text" value="enter one user name" name="username">

Note: if radio is a group, we must give them the same name

3. Radio buttons or check buttons are selected by default


Gender:<input type="radio" name="sex" value="man" checked="checked">male
<input type="radio" name="sex" value="woman" checked="checked">

Code effect:

4. When clicking the text in the tag, the browser will automatically turn the focus (or cursor) to or select the corresponding form element to increase the user experience

Method 1:

<label for="sex1">male</label>
<input type="radio" name="sex" value="man" checked="checked" id="sex1">
<label for="sex2">female</label>
<input type="radio" name="sex" value="woman" checked="checked" id="sex2">

Note: the for attribute of the tag should be the same as the id attribute of the element

Method 2:

<input type="radio" name="sex" value="man" checked="checked">male 
<input type="radio" name="sex" value="woman" checked="checked">female 

Code effect:

  • select drop-down form element


    <option>Option one</option>
     <option>Option 2</option>
     <option>Option 3</option>


1. < Select > contains at least one pair of < option >

2. When selected = "selected" is defined in < option >, the current page is the default option


 <form action="#">
        Native place:
            <option value="">--Please select your city--</option>
            <option value="" >Henan</option>
            <option value="">Hainan</option>
            <!-- <option value="" selected="selected">Yunnan</option> -->
            <option value="" >Yunnan</option>
            <option value="" selected>Annan</option>


Code effect:

  • textarea text field element


<textarea rows="3" cols="20">
Text content


1. The < textarea > tag makes it easy to create multiline text input boxes

2. cols = "number of characters in each line", rows = "number of lines displayed", which will not be used in actual development. css is used to change the size


   <form action="#">
        <!-- cols  Controls the width   -->
        <!-- rows  It controls the height   -->
        introduce oneself to:
        <textarea name="introduction"  cols="10" rows="20" placeholder="I heard you got in the hall and in the kitchen. Why don't you have a partner" >
            Brother, don't worry, love can't turn on you, and the epidemic doesn't matter to you

Code effect:


The above is what I want to talk about today. This article only briefly introduces the use of common HTML tags. Interested friends can learn other tags on the official website. In addition, the tag of HTML5 will be summarized later. The progress of refill update is based on the learning progress. Sometimes it may be delayed. Please forgive me

Keywords: Front-end html

Added by nesargha on Thu, 23 Dec 2021 03:44:43 +0200