Part One: HTML5

Table of contents

1: Web page 

        1.1: What is a web page?

        1.2: What is HTML?

        1.3: The formation of web pages

2: Commonly used browsers

Three: Web standards

        3.1: Why are web standards needed?

        3.2: The composition of Web standards

Four: HTML syntax specifications

        4.1: Basic syntax overview

        4.2: Tag relationship

        4.3: HTML basic structure tags

                4.3.1: The first HTML web page

        4.4: Web development tools: Vscode

                4.4.1: Shortcut keys

        4.5: Common HTML tags

                4.5.1: Tag semantics

                4.5.2: Title tag

                4.5.3: Paragraph tags and line break tags

                4.5.4: Text formatting tags

                4.5.5: <div> and <span> tags

                4.5.6: Image tags and paths

                4.5.7: Hyperlink tags

 Five: Comments and special characters in HTML 

        5.1: Comments

        5.2: Special characters

6: Table label

        6.1: The main function of tables

        6.2: Basic syntax of tables

        6.3: Header cell label

        6.4: Table properties

        6.5: Table structure tag

        6.6: Merge cells

                6.6.1: Merge cells method

                6.6.2: Target cell (write merge code)

                6.6.3: Trilogy of merged cells:

Seven: List tags

        7.1: Classification

Eight: Form tags

        8.1: Why are forms needed?

        8.2: Form composition

        8.2.1: input form element

       8.2.2: Select drop-down form element

       8.2.3: textarea text area element    

        8.3: Tags

1: Web page 
        1.1: What is a web page?

                A website refers to a collection of web pages made using HTML etc. to display specific content on the Internet according to certain rules.

               A web page is a "page" in a website, usually a file in HTML format , which is read through a browser

                Web pages are the basic elements that make up a website. They usually consist of pictures, links, text, sounds, videos and other elements . Usually the web pages we see are files ending with .htm or .html suffix, so they are commonly called HTML files.

        1.2: What is HTML?

                HTML refers to Hyper Text Markup Language , which is a language used to describe web pages

                HTML is not a programming language but a markup language

                A markup language is a set of markup tags

                Two meanings of hypertext:

                        1. It can add pictures, sounds, animations, multimedia and other content (beyond text limitations)
                        2. It can also jump from one file to another and connect to files on hosts around the world (hyperlink text)

        1.3: The formation of web pages

                Web pages are composed of web page elements. These elements are described using html tags and then parsed by the browser to display to the user.

2: Commonly used browsers

        The browser is the platform for displaying and running web pages

        Browser kernel (rendering engine): responsible for reading web page content, organizing information, calculating the display method of web pages, and displaying the page

                At present, most domestic browsers use the Webkit/Blink kernel, such as 360, UC, QQ, Sogou, etc.

Three: Web standards

        Web standards are a collection of standards specified by the W3C (World Wide Web Consortium) organization and other standardization organizations

        3.1: Why are web standards needed?

                ① It can make the pages written by different developers more standard and unified

                ② Make the development prospects of the Web broader

                ③Content can be accessed by a wider range of devices

                ④ Easier to be searched by search engines

                ⑤Reduce website traffic costs

                ⑥Make the website easier to maintain

                ⑦Improve page browsing speed

        3.2: The composition of Web standards

                It mainly includes three aspects : Structure , Presentation and Behavior.

standard illustrate
structure Structure is used to organize and classify web page elements, majoring in HTML
Performance Performance is used to set the layout, color, size and other appearance styles of web page elements. Only CSS is modified.
Behavior Behavior refers to the definition of web page patterns and the writing of interactions, majoring in Javascript

                The best experience solution proposed by Web standards: separation of structure, style and behavior

                Understanding: Structure is written in HTML files, presentation is written in CSS files, and behavior is written in JavaScript files

Four: HTML syntax specifications
        4.1: Basic syntax overview

                1.HTML tags are keywords surrounded by angle brackets, such as <html>

                2.HTML tags usually appear in pairs , such as <html> and </html>, which we call double tags. The first tag in a tag pair is the opening tag and the second is the closing tag

                3. Some special tags must be single tags, such as <br />, which we call single tags.

        4.2: Tag relationship

                Category: inclusion relationship and parallel relationship

1.包含关系
<head>
    <title></title>
</head>

2.并列关系
<head></head>
<body></body>
        4.3: HTML basic structure tags
                4.3.1: The first HTML web page

                        Every web page will have a basic structure tag (also called a skeleton tag), and the page content is also written on these tags.

                        HTML pages are also called HTML documents

  • <!DOCTYPE html>  is declared as an HTML5 document and tells the browser which HTML version to use to display the web page.
  • The <html>  element is the root element of the HTML page
  • The <head>  element contains the meta data of the document, such as <meta charset="utf-8"> defines the web page encoding format as  utf-8 .
  • The <title>  element describes the title of the document
  • The <body>  element contains the visible page content
  • The <h1>  element defines a large title
  • The <p>  element defines a paragraph
        4.4: Web development tools: Vscode
                4.4.1: Shortcut keys

                        ①Quickly copy a line: shift + alt + down arrow (up arrow)

                        ②Select multiple identical words: Ctrl + d

                                First double-click to select a word, then press Ctrl + d to select the same words in sequence.

                        ③Add multiple cursors: Ctrl + alt + up arrow (down arrow)

                        ④Replace certain words globally: Ctrl + h

                                When one of our pages needs to modify a large amount of the same text, it is a bit troublesome for us to modify it one by one. At this time, we can use global replacement.

                        ⑤Quickly locate a certain line: Ctrl + g

                        ⑥Select a block: hold down shift + alt , and then drag the mouse

        4.5: Common HTML tags
                4.5.1: Tag semantics

                        Understand: the meaning of the label, that is, what the label is for

                4.5.2: Title tags <h1>-<h6>

                        In order to make the web page more semantic, we often use title tags in the page

                4.5.3: Paragraph tags and line break tags

                        ① In a web page, if you want to display text in an orderly manner, you need to display the text in segments. In HTML tags, the <p> tag is used to define paragraphs, which can divide the entire web page into several paragraphs

                        ② If you want a certain section of text to force a line break explicitly, you need to use a line break tag<br />

                                The abbreviation of the word break, meaning interruption, line break

                                Features:

                                        1.<br /> is a single tag

                                        2. The <br /> tag simply starts a new line. Unlike paragraphs, some vertical spacing is inserted between paragraphs.     

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h1>标题标签</h1>
    <h1>标题一共六级选</h1>
    <h2>文字加粗一行显</h2>
    <h3>由大到小依次减</h3>
    <h4>从重到轻随之变</h4>
    <h5>语法规范书写后</h5>
    <h6>具体效果刷新见</h6>

    <!-- 段落标签
    特点:
        1.文本在一个段落中会根据浏览器窗口的大小自动换行
        2.段落和段落之间保有空隙
    -->

    <p>超文本标记语言(英语:HyperText Markup Language,简称:HTML)<br />是一种用于创建网页的标准标记语言。
        您可以使用 HTML 来建立自己的 WEB 站点,HTML 运行在浏览器上,由浏览器来解析。</p>

    <p>HELLOWORLD</p>
</body>

</html>
                4.5.4: Text formatting tags

                        In web pages, sometimes you need to set bold , italic or underline effects for text. In this case, you need to use text formatting tags in HTML to display the text in a special way.

                        Tag semantics: highlight importance, more important than ordinary text

                        Text formatting tags:

Label describe
<b><strong> Define bold text
<em> Definition emphasis text, italics
<i> Define italics
<small> Define small font
<strong> Define emphasis
<sub> Define subscript
<sup> Define superscript
<ins> Define caret, underline
<del> Define delete word
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 加粗 -->
    我是<b>加粗</b>的文字
    <br />我是<strong>加粗</strong>的文字!

    <!-- 倾斜 -->
    我是<i>倾斜</i>的文字
    <br />我是<em>倾斜</em>的文字!

    <!-- 删除 -->
    我是<del>删除</del>的文字
    <br />我是<s>删除</s>的文字

    <!-- 下划线 -->
    我是<ins>下划线</ins>
    <br />我是<u>下划线</u>
</body>

</html>
                4.5.5: <div> and <span> tags

These two have no semantics. They are just a box used to hold content.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- <div>标签用来布局,但是现在一行只能放一个<div>,是一个大盒子
         <span>标签用来布局,一行上可以放多个<span>,是一个小盒子
     -->
    <div>我是一个div标签我一个人单独占一行</div>
    <div>我是一个div标签我一个人单独占一行</div>
    <span>新浪</span>
    <span>百度</span>
    <span>搜狐</span>

</body>

</html>
                4.5.6: Image tags and paths

                        ①Image tag

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图像标签</title>
</head>

<body>
    <!-- 在HTML标签中,<img>标签用于定义HTML页面中的图像
         src是<img>标签的必须属性,它用于指定图像文件的路径和文件名
         所谓属性:简单理解是属于这个图像标签的特性

         注意点:
            ①图像标签可以拥有多个属性,必须写在标签名的后面
            ②属性之间不区分先后顺序,标签名与属性、属性与属性之间均以空格分开
            ③属性采取键值对的格式,即key="value"的格式,属性="属性值"
    -->
    <h4>图像标签的使用:</h4>
    <img src="img.png">

    <h4>alt 替换文本 图像显示不出来的时候用文字代替:</h4>
    <img src="img1.png" alt="我是小贾" />

    <h4>title 提示文本 鼠标放到图像上提示的文字:</h4>
    <img src="img.png" alt="我是alt" title="我是小贾" />

    <!-- 设置图像大小 -->
    <h4>图像标签的使用:</h4>
    <img src="img.png" alt="我是alt" title="我是小贾" width="500" height="500" border="15" />
</body>

</html>

                        ②Path

                                (1) Directory folder and root directory

                                        In actual work, our files cannot be placed randomly, otherwise it will be difficult to find them quickly, so we need a folder to manage them.

                                         Directory folder : It is an ordinary folder, which only stores the relevant materials we need to make pages, such as html files, pictures, etc.

                                         Root directory : The first level of the directory folder is the root directory

                                (2) VScode opens the directory folder

                                        File---Open the folder and select the directory folder. Easy to manage later

                                (3) There will be a lot of pictures on the page. Usually we will create a new folder to store these image files. When searching for images, we need to use the "path" method to specify the location of the image files.

                                Paths can be divided into:

                                        1. Relative path: a directory path established based on the location of the referenced file.

                                                For example: the position of the image relative to the HTML page

Relative path classification symbol illustrate
Same level path The image is at the same level as the HTML file
next level path / The image is located one level below the HTML file
Previous level path ../ The image is located one level above the HTML file

                                        2. Absolute path : refers to the absolute position in the directory, directly reaching the target location, usually the path starting from the drive letter (symbol: "\")

                4.5.7: Hyperlink tags

                       In HTML tags, the <a> tag is used to define hyperlinks, which link from one page to another.

                        1. Link definition:

                                HTML uses the <a> tag to set up hypertext links.

                                A hyperlink can be a word, a word, a group of words, or an image. You can click on these contents to jump to a new document or a certain part of the current document.

                                When you move your mouse pointer over a link on a web page, the arrow changes into a little hand.

                                The href attribute is used in the <a> tag to describe the address of the link.

                                By default, the link will appear in the browser as:

  •  An unvisited link appears in blue font and underlined.
  • Visited links appear purple and underlined.
  • When you click a link, it appears red and underlined.

Note: If CSS styles are set for these hyperlinks, the display style will be displayed according to the CSS settings.

                        2. Link syntax format:                                

                                <a herf="Jump target" target="How the target window pops up"> Text or image </a>

                                <a> element: The main HTML element that creates links is <a>the (anchor) element

            <a>The element has the following attributes:

  • href: Specifies the URL address of the link target, which is the most important attribute of the link. It can be the URL of another web page, the URL of a file, or the URL of another resource.
  • target(Optional): Specify how the link opens in the browser. Common values ​​include  _blank(Open link in new tab or window) and  _self(Open link in current tab or window).
  • title(Optional): Provides additional information about the link, usually displayed as a tooltip when the mouse is hovering over the link.
  • rel(Optional): Specify the relationship with the link target, such as nofollow, noopener, etc.   
  • ......                           

                        3. Link classification: six types of links

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <h4>1.外部链接</h4>
    <a href="http://www.qq.com" target="_blank">腾讯</a>
    <!-- 
        target打开窗口的方式:
            默认的值是_self  当前窗口打开页面
                     _blank 新窗口打开页面
     -->

    <h4>2.内部链接:网站内部页面之间的相互链接</h4>
    <a href="07-上一级标签.html" target="_blank">VScode</a>

    <h4>3.空链接:#</h4>
    <a href="#" target="_blank">公司地址</a>

    <h4>4.下载链接:地址链接的是 文件.exe 或者是.zip 等压缩包形式</h4>
    <a href="img.zip">下载文件</a>

    <h4>5.网页元素的链接</h4>
    <a href="http://www.baidu.com"><img src="img.png" /></a>

    <h4>6.锚点链接:当我们点击链接,可以快速定位到页面中的某个位置</h4>
    <!-- 
        1.在链接文本的href属性中,设置属性值为 #名字 的形式,如:<a href="#two"第二集</a>
        2.找到目标位置标签,里面添加一个id属性=刚才的名字,如:<h3 id="two">第二集介绍</h3>
     -->

</body>

</html>
 Five: Comments and special characters in HTML 
        5.1: Comments

                If you need to add some comment text to the HTML document that is easy to read and understand but does not need to be displayed on the page, you need to use comment tags.

                Comments in HTML start with "<!--" and end with "-->"

        5.2: Special characters

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

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 空格 -->
    你&nbsp;&nbsp;&nbsp;&nbsp;好

    <!-- 大于小于 -->
    &lt; p &gt; 是一个段落标签
</body>

</html>
6: Table label
        6.1: The main function of tables

Tables are mainly used to display and display data, because they can make the data display very regular and very readable.

Tables are not for layout, but for displaying data

        6.2: Basic syntax of tables

HTML tables are defined by  the <table> tag .

HTML tables are markup language elements used to display structured data

Each table has several rows (defined by the <tr> tag), each row is divided into several cells (defined by the <td> tag), and the table can contain a header row (<th>) that defines the titles of the columns.

  • tr : tr is the abbreviation of table row, indicating a row of the table
  • td : td is the abbreviation of table data, indicating the data cells of the table
  • th : th is the abbreviation of table header, indicating the header cell of the table

Data cells can contain text, pictures, lists, paragraphs, forms, horizontal lines, tables, etc.

        6.3: Header cell label

Generally, the header cell is located in the first row or column of the table, and the text content in the header cell is bold and centered.

The <th> tag represents the header part of the HTML table

        6.4: Table properties
attribute name attribute value describe
align left、center、right Specifies the alignment of the table relative to surrounding elements
border 1 or "" Specifies whether the table cell has a border. The default is "", which means there is no border.
cellpadding Pixel values Specifies the space between the edge of a single circle and its content, default 2 pixels
cellspacing Pixel values Specifies the space between cells, default 2 pixels
width Pixel value or percentage Specify the width of the table
        6.5: Table structure tag
Label describe
<table> Define table
<th> Define the header of the table
<tr> Define table rows
<td> Define table cells
<caption> Define table title
<colgroup> Define groups of table columns
<col> Define properties for table columns
<thead> Define table header
<tbody> Define the body of the table
<tfoot> Define the footer of the table
        6.6: Merge cells
                6.6.1: Merge cells method

        Merge across rows: rowspan="Number of merged cells"

        Merge across columns: colspan="Number of merged cells"

               6.6.2: Target cell (write merge code)

        跨行:最上侧单元格为目标单元格,写合并代码

        跨列:最左侧单元格为目标单元格,写合并代码

                6.6.3:合并单元格三部曲:

                        1.先确定是跨行还是跨列合并

                        2.找到目标单元格。写上合并方式=合并的单元格数量

                        3.删除多余的单元格

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表格的基本语法</title>
</head>

<body>
    <!-- 这些属性要写到表格标签table里面去 -->
    <table align="center" border="1" cellpadding="0" cellspacing="0" width="900" height="50">
        <thead>
            <tr>
                <!-- 表头单元格 -->
                <th>排名</th>
                <th>关键词</th>
                <th>趋势</th>
                <th>进入搜索</th>
                <th>最近七日</th>
                <th>相关链接</th>
            </tr>
        </thead>

        <tbody>
            <tr>
                <td>1</td>
                <td>鬼吹灯</td>
                <td><img src="下.jpg" </td>
                <td>456</td>
                <td>123</td>
                <td> <a href="#">贴吧</a> <a href="#">图片</a> <a href="#">百科</a> </td>
            </tr>

            <tr>
                <td>2</td>
                <td>盗墓笔记</td>
                <td><img src="下.jpg" </td>
                <td>124</td>
                <td>675432</td>
                <td> <a href="#">贴吧</a> <a href="#">图片</a> <a href="#">百科</a> </td>
            </tr>

            <tr>
                <td>3</td>
                <td>西游记</td>
                <td><img src="上.jpg" </td>
                <td>213</td>
                <td>7654</td>
                <td> <a href="#">贴吧</a> <a href="#">图片</a> <a href="#">百科</a> </td>
            </tr>

            <tr>
                <td>4</td>
                <td>东游记</td>
                <td><img src="上.jpg" </td>
                <td>23</td>
                <td>75643</td>
                <td> <a href="#">贴吧</a> <a href="#">图片</a> <a href="#">百科</a> </td>
            </tr>

            <tr>
                <td>5</td>
                <td>甄嬛传</td>
                <td><img src="下.jpg" </td>
                <td>121</td>
                <td>7676</td>
                <td> <a href="#">贴吧</a> <a href="#">图片</a> <a href="#">百科</a> </td>
            </tr>

            <tr>
                <td>6</td>
                <td>水浒传</td>
                <td><img src="上.jpg" </td>
                <td>576576</td>
                <td>123456</td>
                <td> <a href="#">贴吧</a> <a href="#">图片</a> <a href="#">百科</a> </td>
            </tr>
        </tbody>
    </table>
</body>

</html>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <table width="500" height="249" border="1" cellspacing="0">
        <tr>
            <!-- 将第一行的第二个单元格和第三个单元格合并 -->
            <td></td>
            <td colspan="2"></td>
        </tr>

        <tr>
            <!-- 将第二行的第一个单元格和第三行的第一个单元格合并 -->
            <td rowspan="2"></td>
            <td></td>
            <td></td>
        </tr>

        <tr>
            <td></td>
            <td></td>
        </tr>
    </table>
</body>

</html>
七:列表标签

        表格是用来显示数据的,那么列表就是用来布局的

        列表最大的特点:整齐、整洁、有序,它作为布局会更加自由和方便

        7.1:分类

1.无序列表

        无序列表是一个项目的列表,此列项目使用粗体圆点(典型的小黑圆圈)进行标记,列表项使用<li>标签定义

        无序列表使用 <ul> 标签

        注意:       

                ①无序列表的各个列表项之间没有顺序级别之分,是并列的

                ②<ul></ul>中只能嵌套<li></li>,直接在<ul></ul>标签中输入其他标签或文字的做法是不被允许的

                ③<li></li>之间相当于一个容器,可以容纳所有元素

                ④无序列表会带有自己的样式属性,但在实际使用时,我们会使用CSS来设置

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>无序列表</title>
</head>

<body>
    <h4>您喜欢的食物?</h4>
    <u1>
        <li>榴莲</li>
        <li>臭豆腐</li>
        <li>鲱鱼罐头</li>
    </u1>
</body>

</html>

2.有序列表

        有序列表是一列项目,列表项目使用数字进行标记。 有序列表始于 <ol> 标签。每个列表项始于 <li> 标签

        列表项使用数字来标记

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>有序列表</title>
</head>

<body>
    <h4>粉丝排行榜</h4>
    <ol>
        <li>刘德华 10000</li>
        <li>张学友 88888</li>
        <li>小贾 1</li>
    </ol>
</body>

</html>

3.自定义列表

        自定义列表不仅仅是一列项目,而是项目及其注释的组合

        自定义列表以 <dl> 标签开始,每个自定义列表项以 <dt> 开始,每个自定义列表项的定义以 <dd> 开始

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自定义列表</title>
</head>

<body>
    <dl>
        <dt>关注我们</dt>
        <dd>新浪微博</dd>
        <dd>官方微信</dd>
        <dd>联系我们</dd>
    </dl>
</body>

</html>

ul是unordered lists的缩写 (无序列表)

li是list item的缩写 (列表项目)

ol是ordered lists的缩写(有序列表)

dl是definition lists的英文缩写 (自定义列表)

dt是definition term的缩写 (自定义列表组)

dd是definition description的缩写(自定义列表描述)

tr是table row的缩写 (表格中的一行)

th是table header cell的缩写 (表格中的表头)

td是table data cell的缩写 (表格中的一个单元格)

八:表单标签
        8.1:为什么需要表单?

使用表单目的是为了收集用户信息

在我们的网页中,我们也需要跟用户进行交互,收集用户信息,此时就需要表单

        8.2:表单的组成

在HTML中,一个完整的表单通常由表单域表单控件(也称为表单元素)和提示信息3个部分组成

        ①表单域

        表单域是一个包含表单元素的区域

        在HTML标签中,<form>标签用于定义表单域,以实现用户信息的收集和传递

        <form>会把它范围内的表单元素信息提交给服务器

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表单域</title>
</head>
<body>
    <form action="demo.php" method="post" name="name1">
        
    </form>
</body>
</html>

        常用属性:

属性 属性值 作用
action url地址 用于指定接收并处理表单数据的服务器的url地址
method get/post 用于设置表单数据的提交方式,其取值为get或post
name 名称 用于指定表单的名称,以区分同一个页面中的多个表单域

        ②表单控件(表单元素)

        表单元素是允许用户在表单中输入内容,比如:文本域(textarea)、下拉列表(select)、单选框(radio-buttons)、复选框(checkbox) 等等

        8.2.1:input输入表单元素

        多数情况下被用到的表单标签是输入标签 <input>:用于收集用户信息

        输入类型是由 type 属性定义

        文本域通过 <input type="text"> 标签来设定,当用户要在表单中键入字母、数字等内容时,就会用到文本域

        密码字段通过标签 <input type="password"> 来定义

        <input type="radio"> 标签定义了表单的单选框选项

        <input type="checkbox"> 定义了复选框

                复选框可以选取一个或多个选项

        <input type="submit"> 定义了提交按钮

                当用户单击确认按钮时,表单的内容会被传送到服务器。表单的动作属性 action 定义了服务端的文件名

                action 属性会对接收到的用户输入数据进行相关的处理

        注意:

                ①name和value是每个表单元素都有的属性值,主要给后台人员使用

                ②name表单元素的名字,要求单选按钮和复选框要有相同的name值

                ③checked属性主要针对于单选按钮和复选框,主要作用:一打开页面,就可以默认选中某个表单元素

                ④maxlength是用户可以在表单输入的最大字符数,一般较少使用

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>input 表单元素</title>
</head>

<body>
    <form action="xxx.php" method="get">
        <!-- text 文本框 用户可以在里面输入任何文字 -->
        用户名:<input type="text" name="username" value="请输入用户名" maxlength="6"> <br>

        <!-- password 密码框 用户看不见输入的密码 -->
        密码:<input type="password" name="pwd"> <br>

        <!-- radio 单选框 可以实现多选一 -->
        <!-- name 是表单元素名字 这里性别单选按钮必须有相同的名字name才可以实现多选一 -->
        <!-- 单选按钮和复选框可以设置checked属性,当页面打开的时候可以默认选中这个按钮 -->
        性别:男 <input type="radio" name="sex" value="男">
        女 <input type="radio" name="sex" value="女" checked="checked"> <br>

        <!-- checkbox 多选框 可以实现多选 -->
        爱好:吃饭<input type="checkbox" name="hobby"> 睡觉<input type="checkbox" name="hobby"> 打游戏 <input type="checkbox"
            name="hobby"> <br>

        <!-- 点击了提交按钮,就可以把表单域form里面的表单元素里面的值提交给后台服务器 -->
        <input type="submit" value="免费注册">

        <!-- 重置按钮可以还原表单元素初始的默认状态 -->
        <input type="reset" value="重新设置">

        <!-- 普通按钮button 后期结合js搭配使用 -->
        <input type="button" value="获取短信验证码">

        <!-- 文件域 使用场景 上传文件时使用 -->
        上传头像:<input type="file">
    </form>
</body>

</html>
       8.2.2:select下拉表单元素

在页面中,如果有多个选项让用户选择,并且想要节约页面空间时,我们可以使用<select>标签控件定义下拉列表

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>select 下拉表单</title>
</head>

<body>
    <form>
        籍贯:
        <select>
            <option>山东</option>
            <option>北京</option>
            <option>陕西</option>
            <option selected="selected">上海</option>
        </select>
    </form>

</body>

</html>
       8.2.3:textarea文本域元素    

使用场景:当用户输入内容较多的情况下,我们就不能使用文本框表单了,此时我们可以使用<textarea>标签

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>testarea 文本域</title>
</head>

<body>
    <form>
        今日反馈:
        <textarea cols="50" rows="5">helloworld!
        </textarea>
    </form>
</body>

</html>
8.3:<label>标签
<label>标签为input元素定义标注(标签)

<label>标签用于绑定一个表单元素,当点击<label>标签内的文本时,浏览器就会自动将焦点(光标)转到或者选择对应的表单元素上,用来增加用户体验

Core: The for attribute of the <label> tag should be the same as the id attribute of the related element

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>label 标签</title>
</head>

<body>
    <label for="text"> 用户名:</label> <input type="text" id="text">

    <input type="radio" id="nan"> <label for="nan">男</label>
</body>

</html>

Guess you like

Origin blog.csdn.net/weixin_63925896/article/details/133209763