Table common labels and attributes (basic use of table labels, table structure and common lists, custom lists and forms, form input, form input)

Posted by techrat on Thu, 16 Dec 2021 11:35:30 +0100

1. Common labels and attributes of tables

1.1 basic use of form labels

What is the main function of the form?

  • Display data neatly in rows and columns (tables), such as stock prices
  • Layout pages in tables

Basic syntax of table:

<table>
  <tr>
    <td>Cell content</td>
    ... //Repeat td → cell
  </tr>
  ... //Repeat tr → line
</table>

How many table labels are commonly used? What do they mean?

Three basic table labels:

Serial numberTag nameexplain
1tableTable label for containing multiple TRS
2trDefines a row in a table that contains more than one td
3tdDefine the cells in the table to store the cell contents

be careful:

  • Table and tr are used to build a table structure and cannot store the actual content;
  • td is used to store cell data.
<table>
        <tr>
            <td>Serial number</td>
            <td>full name</td>
            <td>Gender</td>
        </tr>
        <tr>
            <td>1</td>
            <td>Zhang San</td>
            <td>male</td>
        </tr>
        <tr>
            <td>2</td>
            <td>Li Si</td>
            <td>male</td>
        </tr>
        <tr>
            <td>3</td>
            <td>Wang Wu</td>
            <td>female</td>
        </tr>
    </table>

1.2 header cell label

What is the function of header label?

The first row is usually used to display the title rather than the actual data, which is convenient for users to read and understand the meaning of the data in the lower table

What is the label?

th can also store content, but it will be bold and centered by default.

<table>
        <th>
            <td>Serial number</td>
            <td>full name</td>
            <td>Gender</td>
        </th>
        <tr>
            <td></td>
            <td>1</td>
            <td>Zhang San</td>
            <td>male</td>
        </tr>
        <tr>
            <td></td>
            <td>2</td>
            <td>Li Si</td>
            <td>male</td>
        </tr>
        <tr>
            <td></td>
            <td>3</td>
            <td>Wang Wu</td>
            <td>female</td>
        </tr>
    </table>

1.3 table related attributes

In which label should the table attributes be written? Why?

Attributes are used to describe the characteristics (display effect) of the tag, so attributes should be written in the table tag

Attribute grammar review:

<table Attribute 1="Value 1" Attribute 2="Value 2"></table>

be careful:

  • Attribute names do not require quotation marks
  • Attribute values must be quoted, usually in double quotes
  • Attribute = "value" is also called key value pair - attribute name: key / attribute value: value / pair
  • Each key value pair is separated by a space
    Common attributes of tables:
Attribute nameAttribute valuedescribe
alignleft,center,rightAlignment
borderWidth pixel value or ''Table border, default "" no border
widthPixel valuewidth
heightPixel valueheight
cellspacingPixel valueSpacing between cells, default 2 pixels
cellpaddingPixel valueThe distance between the content and the border, which is 1 pixel by default

Center the table, and set the table border, width, height, content spacing and cell spacing.

<table  align="center" border="1" cellpadding="20" cellspacing="0" width="500" height="100">
        <th>
            <td>Serial number</td>
            <td>full name</td>
            <td>Gender</td>
        </th>
        <tr>
            <td></td>
            <td>1</td>
            <td>Zhang San</td>
            <td>male</td>
        </tr>
            <td></td>
            <td>2</td>
            <td>Li Si</td>
            <td>male</td>
        </tr>
            <td></td>
            <td>3</td>
            <td>Wang Wu</td>
            <td>female</td>
        </tr>
    </table>

2. Table structure and common list

2.1 table structure label

In terms of semantics, what two areas can a table be divided into? What labels do they correspond to?

In terms of semantics, a table can be divided into the following two areas:

  • thead defines the table header (header row). It must have a tr label, which is usually located in the first row
  • tbody defines the body of the table and usually contains the table data area below the header row
    Note: thead and tbody are only used to divide the table structure and distinguish the header row and data area. They cannot replace the original tr, th and td tags.

2.2 merging cells

What are two ways to merge cells?

How to merge cells:

  • Cross row merge (rowspan): merge cells of multiple rows → vertical merge
  • colspan: merge cells of multiple columns → merge horizontally

What are the steps to merge cells?

  1. Specify the consolidation method (cross row / cross column)
  2. Find the target cell td and add the merged cell attribute
  • Cross row rowspan="x" (vertical)
  • Straddle colspan="y" (landscape)
<table align="center" width="640" height="240" cellspacing="1" cellpadding="20" border="2">
        <thead>
            <tr>
                <th colspan="4">Student information</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>full name:</td>
                <td>Ju Xiaoshuai</td>
                <td>Class:</td>
                <td>Hefei phase 10</td>
            </tr>
            <tr>
                <td>date of birth:</td>
                <td>2000-02-14</td>
                <td>Gender:</td>
                <td>Xiaoshuai</td>
            </tr>
            <tr>
                <td>cell-phone number:</td>
                <td>110</td>
                <td>wechat number:</td>
                <td>119</td>
            </tr>
        </tbody>
    </table>
  1. Delete extra cells

2.3 unordered list

What is the main purpose of the list?

Lists are used for layout. They can display data in a neat and orderly manner. Using lists for layout will be more free and convenient;

How many lists do we have to learn?

  • Unordered list (ul)
  • Ordered list (ol)
  • Custom list (dl)

How many tags are there in the unordered list? What are they and what are their functions? What are the precautions?

Basic syntax for unordered lists:

   <ul>
      <li>List item</li>
      <li>List item</li>
      <li>List item</li>
      ...
   </ul>

Two unordered list labels:

  • ul unordered list. Only multiple li tags are allowed
  • Liused to store the contents of li st items
    be careful:
  • ul is used to build a structure and cannot store the actual content;
  • ul only allows multiple li tags;
  • li is used to store list item data

2.4 with sequence table

What is the difference between an ordered list and an unordered list?

The ordered list ol will automatically add numerical sorting in front of the list items, and the sorting will increase in turn;

The basic syntax of an ordered list is basically the same as that of an unordered list. You only need to replace ul with ol:

    <ol>
      <li>List item</li>
      <li>List item</li>
      <li>List item</li>
      ...
    </ol>

Is there any difference between the use and precautions of ordered list and unordered list except sequence number?

In addition to the serial number, the ordered list is no different from the use and precautions of the unordered list.

3. Customize lists and forms

3.1 custom list

What are the application scenarios for custom lists?

The website navigation below the website home page can usually be realized by using a custom list
Basic syntax for custom lists:

<dl>
  <dt></dt>
  <dd>
    ...
  </dd>

  <dt></dt>
  <dd>
    ...
  </dd>
</dl>

Note: Although a dl can contain multiple DTS, it usually contains only one dt in actual development, because it is more convenient for layout

How many labels are there in the custom list? What do they mean?

Three custom list labels:

Serial numberTag nameexplain
1dlCustom list, only dt and dd tags are allowed
2dtIt is used to store keyword (term) content. It is brotherly with dd, but subsequent dd follows the previous dt
3ddIt is used to store the list item contents of the previous dt keywords

3.3 form usage scenarios and classification

What is the application scenario of the form?

When developing a website, you can use forms to collect user information and submit it to the background for processing;

What parts does the form consist of?

A form usually consists of three parts:

  1. Form field: the entire form area summarizes the data to be collected and submits it to the background. For example, it contains complete user information records such as name and gender;
  2. Form control (form element): interact with users, allowing users to enter or select a single specific information, such as name;
  3. Prompt information: prompt the user what information each form control collects.

3.4 form fields

What is the role of a form field?

  • Realize the collection and transmission of user information, such as collecting the complete information of users, and then uniformly transmitting it to the background;
  • Basic syntax of the form:
    <form>
      ... form control  ... Prompt information
    </form>

3.5 input type attribute text box and password box

What is the role of form controls?

Users can input or select content through form controls to achieve the purpose of collecting information through forms.

How many categories can form controls be divided into?

Form controls include the following three categories:

  1. Input input
  2. Select select
  3. textarea text field

Basic syntax of input tag:

  <input type="Attribute value" />

Common attribute values of type:

typeAttribute valuedescribe
inputtextEnter text
inputpasswordpassword
choiceradioRadio button, select one more
choicecheckboxCheck box (tick)
Click to select a filefileFile upload use
clickbuttonButton
clickimageButton
Form operationsubmitSubmit and send the data to the server
Form operationresetReset will clear all data in the form

4. Form input

4.1 ☆ input type attribute submission and reset button

What is the function of the submit button?

The submit button can submit the data in the form field to the background

What is the function of the reset button?

The reset button can clear the data in the form field

What is the use of the value attribute?

The value attribute allows you to specify the text in the submit button or reset button

4.2 radio button and check box of input type attribute

What are the application scenarios for radio boxes?

When selecting more than one, use the radio, such as gender;

What is the application scenario of the check box?

When selecting more than one, use the checkbox, such as hobbies.

Note: during development, it is not suitable to provide too many options, whether single choice or check

4.3 name and value attributes of input

Which property can distinguish form controls? (different controls are responsible for collecting different information)

  • The name attribute can distinguish form controls
  • The value property can record the value entered by the user in the control or the selection result

How can users be allowed to select only one item among multiple radio buttons?

For the same set of radio boxes or check boxes, the value of the name attribute should be consistent

5. Form input

5.1 checked and maxlength attributes of input

What is the application scenario of the checked attribute?

  • If the user wants to modify the previously saved information, the checked attribute can select the user's previous selection, for example, modify personal information
  • The checked attribute can help users agree to the user agreement by default;

What is the application scenario of maxlength attribute?

  • When the input item in the input box has a length limit, you can use the maxlength attribute;
    Common attributes of the input tag:
attributedescribe
typetype
nameName that distinguishes the control
valueValue that records or sets the value of the control
checkedA radio or check box is selected by default
maxlengthMaximum input length of input box

Note: in H5, checked="checked" can be abbreviated as checked.

5.2 type attribute of input ordinary button and file field

Which attribute can set the display text of ordinary buttons?

The value attribute can be used to set the attribute value of ordinary buttons

What is the value of the type attribute of the uploaded file?

The type attribute value of the uploaded file is file;

Can I submit the form by clicking the normal button?

Clicking the normal button cannot submit the form. After learning JavaScript, the normal button is very useful.

5.3 label

What is the function of label?

label can be bound to the elements in the form to increase the click range and improve the user experience

What are the steps to use the label?

Steps:

  1. Set a unique id attribute value for the input tag to be bound;
  2. Use < label for = "control ID" > label text < / label > to bind the label to the corresponding control.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>label label</title>
</head>
<body>
    <form action="demo.php" method="get">
        <!-- Required action Property specifies where to send form data when the form is submitted. -->
        <dl>
            <dt><h4>User information</h4></dt>
        </dl>
        user name:<input type="text" value="enter one user name" maxlength="6"><br>
        <!-- input	text	Enter text -->
        dense &nbsp; Code:<input type="password" name="password" value="password"><br>
        <!-- input	password	password -->
        Gender: Male<input type="radio" name="sex" checked>female<input type="radio" name="sex">Simon?<input type="radio" name="sex"><br>
        <!-- choice	radio	Radio button, select one more -->
        Hobbies: all<input type="checkbox" name="hobby" checked='checked' id="basketball"><label for="basketball"> Basketball</label><input type="checkbox" name="hobby" id="football"><label for="football">Football</label><input type="checkbox" name="hobby" id="sing"><label for="sing">sing</label><input type="checkbox" name="hobby" id="dance"><label for="dance">dance</label><input type="checkbox" name="hobby"><br>
        <!-- choice	checkbox	Check box (tick) -->
        File upload:<input type="file" name="file" id=""><br>
        <!-- Click to select a file	file	File upload use -->
        button Button: <input type="button" value="Get SMS verification code"><br>
        <!-- click	button	Button -->
        Upload Avatar:<input type="image" value="images"><br>
        <input type="submit" value="Submit">
        <!-- Form operation	submit	Submit and send the data to the server -->
        <input type="reset" value="Reset">
        <!-- Form operation	reset	Reset will clear all data in the form -->
    </form>
</body>
</html>

5.4 select drop-down form

What is the application scenario of the drop-down list?

There are too many options. If you want to save space and improve the user experience, you can use the drop-down list

Basic syntax of drop-down list:

    <select>
      <option>Option 1</option>
      <option>Option 2</option>
      <option>Option 3</option>
      ...
    </select>

How many labels are there in the drop-down list? What do they mean?

  • Labels for three drop-down lists:

    Serial numberTag nameexplain
    1selectDrop down list
    2optionDrop down list options for storing options
    3selectedProperty can select an item by default.

    In H5, selected = "selected" can be abbreviated as selected.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>select Drop down form</title>
</head>
<body>
    List of options
    <select>
        <!-- Drop down list -->
        <option value="">List 1</option>
        <!-- Drop down list options for storing options -->
        <option value="">List 2</option>
        <option value="">Listing 3</option>
        <option value="">Listing 4</option>
        <option value="">Listing 5</option>
        <option value="">Listing 6</option>
        <option value="" selected>Listing 7</option>
        <!-- use selected Property can select an item by default. -->
    </select>
</body>
</html>

appendix

1. Label

Table label

Serial numberTag nameexplain
1tableTable label for containing multiple TRS
2trDefines a row in a table that contains more than one td
3tdDefine the cells in the table to store the cell contents
4thDefines the cell in the header. It is used to store the cell content. It is bold and centered by default
5theadTo define the table header (header row), you must have a tr label
6tbodyDefines the body of the table, usually including the table data area below the header row

List label

Serial numberTag nameexplain
1ulUnordered list. Only multiple li tags are allowed
2olOrdered list, only multiple li tags are allowed
3liUsed to store the contents of list items
4dlCustom list, only dt and dd tags are allowed
5dtIt is used to store keyword content. It is brotherly with dd, but subsequent dd follows the previous dt
6ddIt is used to store the list item contents of the previous dt keywords

Form label

Serial numberTag nameexplain
1formDefine form fields and uniformly collect and transfer data
2inputInput control, which can be text box, radio, check, select file, button, etc
3selectDrop down list
4optionDrop down list options for storing options

Common attributes of the input tag:

attributedescribe
typetype
nameName that distinguishes the control
valueValue that records or sets the value of the control
checkedA radio or check box is selected by default
idControl ID, used with label label
maxlengthMaximum input length of input box

Common attribute values of input tag type:

typeAttribute valuedescribe
inputtextEnter text
inputpasswordpassword
choiceradioRadio button, select one more
choicecheckboxCheck box (tick)
Click to select a filefileFile upload use
clickbuttonButton
clickimageButton
Form operationsubmitSubmit and send the data to the server
Form operationresetReset will clear all data in the form

2. Shortcut keys

VSCode shortcut key

Shortcut keyeffect
ctrl + nnew file
ctrl + sSave file
ctrl + zrevoke
ctrl + shift + zResume undo
ctrl + plus / minusZoom in / out
ctrl + c / vCopy and paste a line (text cannot be selected)
ctrl + xDelete a row
alt + ↑ / ↓Move code up and down
alt + shift + ↑ / ↓Copy one line of code up and down
ctrl + /notes
ctrl + dMulti select the same content backward
alt + zAuto wrap

Emmet syntax

ul>li*6{h$}

dl>dt+dd*3

Key words

Serial numberEnglishchinese
1tableform
2rowthat 's ok
3datadata
4alignalignment
5leftLeft
6centerin
7rightright
8cellCell
9spacingDistance between the outside and each other
10paddingThe distance between the inner margin (filler) content and the border
11rowthat 's ok
12col / columncolumn
13termterm
14inputinput
15selectchoice
16selectedSelected
17arearegion
18typetype
19submitSubmit
20resetReset
21nameName, name
22valuevalue
23radioRadio
24checkboxCheckbox
25optionoption

Topics: Front-end html5 html css