HTML basics summary

Posted by tekcap on Sun, 20 Feb 2022 05:11:49 +0100

catalogue

Block element

Form form

form validation:

 action:

keyword:

button:

Common block labels

list

form

Row element

Common row element labels

a: Hyperlink label

Inline block element

img: import pictures

Input: input box

Type: input box type

Input box content

Label: expand the selection area

textarea: multi line input box

Button button

select: drop-down list

Block element

Exclusive row, width and height can be set. display:block;

Form form

form validation:

<form action="http://www.baidu.com/s">
    <!-- required Required -->
    <!-- \d Regular expression, representing 0-9 Numbers,{1,}1 One or more numbers,{11}11 Digits,{1,10}1-10 Digit number -->
    <input type="text" name="wd" required pattern="\d{1,10}" id="wd">
    <button type="submit">Submit</button>
</form>

required attribute: make the input tag mandatory

pattern = "regular expression \ d"

\d regular expression {represents 0-9 digits {1,} 1 or more digits {11} 11 digits {1,10} 1-10 digits

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8"/>
  <title> New Document </title>
</head> 
<body>
    <form>
        <input id="user" type="text" required pattern="^[a-zA-Z0-9]{6,12}$" placeholder="enter one user name"/>
        <input type="submit" value="Submit">
    </form>
</body>
<script>
var user=document.getElementById("user");
    user.onblur=function(){
        if(user.value){
            user.setCustomValidity("");//The prompt for input is now set to blank
        }else if(user.validity.valueMissing){
            user.setCustomValidity("User name cannot be empty");  // Modify prompt
        };
        if(user.validity.patternMismatch){ 
            user.setCustomValidity("The user name can only be in English or numbers, with a length of 6 to 12 digits"); // Modify prompt
        }
    };
</script>
</html>

 action:

The address is submitted inside

<!-- ?The previous page address is followed by the search criteria (the fields passed to the back end) -->
<!-- keyword=Air conditioning key value pair =The front is the key =Followed by multiple key value pairs&Symbolic link -->
<form action="https://www.mi.com/search">
    <input type="text" name="keyword">
    <button type="submit">Submit</button>
</form>

keyword:

name will add the previous search condition wd=xxx (the content of the input box) after the path

<input type="text" name="wd">

button:

<!-- Function: modify form Form, jump and carry name To the back of the path -->
<button type="submit">Submit</button>
<!-- effect: reset Reset all items in the form -->
<button type="reset">Reset</button>
<!-- 1.And the two above button Same effect -->
<!-- 2.No value Default display reset style, plus value Cannot be empty. The style words in the browser box are displayed as value Words set in -->
<input type="submit">
<input type="reset" value="111">

Common block labels

div: Universal container, divider

p: Paragraph label

h1-h6: title label

hr: split line

list

ol, li: ordered list

ul, li: unordered list

form

tr: define rows

td: define column (th: header, font centered, bold) (both are used in tr label)

  1. cellpadding the inner margin of a cell
  2. Distance between cells
  3. Border table border
  4. align alignment (only three right, left and center)
  5. The width height property is not a style
  6. colspan merge columns
  7. rowspan merge rows

Row element

Multiple labels are displayed in one line. The width, height, and upper and lower margins cannot be set. They can only be supported by the content (arranged horizontally, not exclusive to one line, and always arranged if there is a position on the right. The width and height cannot be set directly) display:inline;

Common row element labels

span: displays a small amount of text

b. strong: bold font

i. em: font tilt

u: Underline

sup\sub: superscript / subscript

s\del: delete line

a: Hyperlink label

  1. External link: directly add the page path of jump in href
  2. Internal link:/+ Another html
  3. Empty link: if the href is empty, click to refresh the current page -- if there is only one # in the href, click to directly return to the top of the page without refreshing the page
  4. Download link:/+ Downloaded content
  5. Nest other elements: add links to them
  6. Anchor link: set a unique identification id for the located target. The value of the id attribute cannot be repeated
    <a href="#position">
    <div id="position">
  7. href - target: _ self jump to the current page and there will be a history (default)_ balnk opens a new page and jumps. There is no history.

Inline block element

Multiple intra row block labels can be displayed in one row, and the width and height can be directly set (the default is horizontal arrangement, and the line breaks only when the right position is not enough) display: inline block;

The default vertical alignment of inline block elements is baseline alignment
vertical-align: top; Top line alignment

img: import pictures

  1. src: picture address

    Relative path:/ Current directory.. // Upper level directory/ Parent directory / root directory and network address of the current project

    Absolute path: starting from the drive letter (C:), not recommended

  2. alt: when there is a problem with the picture display, the content in alt will replace the picture display. When there is a problem with the picture display, the content in alt will replace the picture display

Input: input box

Type: input box type

  1. Text: text input box

    maxlength = "" the maximum length that can be entered in the input box

    autofocus ― automatically get the focus (refresh is in the inputable state by default)

    disabled: disable the input box (the input content in the input box cannot be expected)

  2. Number: number input box [only numbers can be entered]

    min = "" enter the minimum number of digits

    step: increase or decrease the value of each click

  3. Password: password input box
  4. data: date selection box

    type is week: Week selector (week of the year)

    type is month: month selector (XX month of XX year)

  5. Data time local: local date and time selection box, type time: event selector
  6. Color: color selector
  7. checkbox: check box
  8. Radio: radio box
  9. Range: range slider
  10. File: Upload File Box Multi file upload: < input type = "file" multiple > Folder upload: < input type = "file" WebKit Directory >
  11. Image: image
  12. Hidden: hidden

Input box content

placeholder is the prompt message displayed when there is no content in the input box, (unable to operate)

Contents in the value input box (operable)

Label: expand the selection area

The value of for corresponds to the value of id

<label for="username">full name:</label>
<input type="text" id="username">

For multiple IDS, only the first one will take effect [id is the unique id]

It can be used with radio and can be selected without adding name. Using the same name can not enable both at the same time to play the role of selection

<label>
        <input type="radio" name="gender">male
    </label>
    <label>
        <input type="radio" name="gender">female
    </label>

textarea: multi line input box

cols = "" controls the number of columns in the input box (not accurate in different browsers)
Rows = "" controls the number of rows in the input box
If it is not set, the default is 2 rows and 11 columns. It is not recommended to use it. Set the width and height directly with the style

The contents of textarea will retain line breaks and spaces

maxlength controls the maximum character length that can be entered

<textarea cols="30" rows="10" placeholder="Please enter comments">Braised big carp in yellow sauce</textarea>
<textarea cols="30" rows="10" placeholder="Please enter comments">                            Braised big carp in yellow sauce</textarea>
<textarea cols="30" rows="10" placeholder="Please enter comments">braise in brown sauce    Big carp</textarea>

Button button

select: drop-down list

  1. Option: list option , selected changes the default selected item
  2. optgroup: option group
    <select>
            <!-- optgroup  Option group -->
            <optgroup label="meat or fish dishes">
                <option>Braised chicken in yellow sauce</option>
                <option>Stewed mushroom with chicken</option>
            </optgroup>
            <optgroup label="vegetable dish">
                <option selected>Seaweed and Egg Soup</option>
            </optgroup>
        </select>

  3. Shared with js

  4. The drop-down box submits the value attribute. If it is not set, the default submission is the selected content; If the value submitted is set to be the value

In addition:

Format label # pre: the default font is 13px, and the content indentation and line feed are reserved # Center: the content is displayed in the center of the parent element # br line feed

Semantic tags (what tags put what content , conducive to SEO (tags with their own meaning are semantic tags) eg: h tags put Title , p tags put paragraph text)

Topics: Front-end html