search
HomeWeb Front-endH5 TutorialSummary of new elements and tags in HTML5

I always encounter written test questions about h5 new tags, so I checked the information to summarize:

1.form related:

(1) form attribute: In HTML5, form elements can be placed outside the form, by giving the Just add the form attribute to the element to point to the target form (set the form attribute value to the target form id).

(2) formaction attribute: HTML5 adds the formaction attribute to submission buttons (such as button, submit, image, etc.) to facilitate submission to different server addresses.

<input formaction="new.html" type="submit" value="提交到new.html">

(3) formmethod attribute: The usage is the same as formaction.

(4) placeholder attribute: a text prompt used when the text box is in an uninput state.

(5) autofocus attribute: Automatically obtain focus. Only one control on a page can have this attribute. This attribute has no value, just write it directly.

<input name="username" autofocus type="text" id="username">

(6) list attribute: used for single-line text boxes. The value of this attribute is the id of a certain datalist element. The single-line text box after adding this attribute is similar to a select box (select), but allows users to customize input. In order To avoid errors in browsers that do not support this element, we usually use CSS to set it not to display.

Tag: Define a list of optional data. Used in conjunction with the input element, you can create a drop-down list of input values.

order:<input list="list" name="order" autofocus type="text" id="order">
            <datalist id="list" style="display:none">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            </datalist>

(7) autocomplete attribute: Autocomplete allows the browser to predict the input to the field. HTML5 implements custom setting of this attribute to avoid security risks that can be seen by anyone. This attribute has three values: "on", "off" or "" (not specified). If not specified, the browser's default value is used.

(8) Input element type:

Search: Similar to text text box, used for search;

Tel: Similar to text text box, used for phone calls;

url: Similar to text text box, used for url Format address;

email: Similar to the text text box, used for email format addresses;

number: Similar to the text text box, used for numerical values;

range: Only allowed to enter values ​​within a range, through min and max attribute to set the range;

color: color text box, text in "#000000" format;

file: file selection text box, multiple selections can be made through the multiple attribute in HTML5;

datetime, date, month, week , time, datetime-local Text boxes for various date and time inputs;

Output: Define different types of output;

(9) Form verification related:

Automatic verification (achieved by adding corresponding attributes to elements Verification requirements)

 Required attribute: Elements with this attribute are not allowed to be submitted if their content is empty, and a corresponding prompt is given.

  Pattern attribute: For elements with this attribute, if the content is not empty, the content will be matched with the pattern value. If the match is unsuccessful, it will not pass and a prompt will appear.

 Min attribute and max attribute: They are special attributes for input elements of value type and date type, which limit the input range.

 Step attribute: Controls the step by which the value of an element increases or decreases. For example, if you enter a number between 1-100 and the step is 5, you can only enter 1, 6, 11....

 Display verification (in addition to adding attributes to elements for automatic verification, in HTML5, form elements and input elements (input) including select elements and textarea have a checkValidity method, which can be manually verified by calling this method. The checkValidity method starts with boolean The form returns the verification result)

function check(){
        var email=document.getElementById("email");
        if(email.checkValidity()){
        alert("email格式正确");
        }else{
        alert("email格式不正确");
        }
        }

Cancel verification (cancel form verification has two attributes: novalidate for form and formnovalidate for submit)

//用于form的novalidate
        <form novalidate>
        <input type="text" name="name" id="name" required>
        <input type="submit" name="button" id="button" value="提交">
        </form>

        //用于submit的formnovalidate
        <form>
        <input type="text" name="name" id="name" required>
        <input type="submit" orfmnovalidate name="button" id="button" value="提交">
        </form>

Custom error: In HTML5, the form browser that has not been verified will There are default prompts, but also provide custom error prompts through JavaScript. (I think I just need to write a function myself and call it when I click).

2. Enhanced page elements

(1) figure element: figure is a combination element that can have a title figcaption, and a figure only allows one figcaption to be placed.

        <figure>
        <img src="/static/imghwm/default1.png"  data-src="logo.png"  class="lazy"   alt="Summary of new elements and tags in HTML5">
        <figcaption>标志</figcaption>
        </figure>

(2) details element: details provides an alternative to Javascript to expand or contract local areas on the screen.

        <details>
        <summary>点击我查看细节</summary>
        <p>我是细节内容。</p>
        </details>

(3) mark element: the mark element indicates that the page needs to be highlighted or highlighted part.

(4) Progress element: Generally used to write progress bars. You can set the value and max attributes for progress. Value represents what has been carried out, and max represents the total number. Value and max can only be valid floating point numbers. Value must be greater than 0 and less than equal to max. If you do not set these two attributes for progress, the dynamic display is in progress and the progress is uncertain.

(5) meter element: Define weights and measures. (The upper and lower values ​​​​will be distinguished by color).

   high:定义度量的值位于哪个点,被界定为高的值。
        low:定义度量的值位于哪个点,被界定为低的值。
        max:定义最大值。默认值是 1。
        min:定义最小值。默认值是 0。
        optimum:定义什么样的度量值是最佳的值,如果该值高于 "high" 属性,则意味着值越高越好。如果该值低于 "low" 属性的值,则意味着值越低越好。
        value:定义度量的值。

(6)改良的ol列表:在HTML5中为ol元素添加了start属性和reversed属性。

  start:表示列表序号从几开始。

  reversed:表示列表序号为倒序。

(7) 改良的dl列表:dl是专门用来定义术语的列表,在HTML5中为dt增加了名字dfn。

        <dl>
        <dt>术语1</dt>
        <dd>描述...</dd>
        <dt><dfn>名字</dfn>术语2</dt>
        <dd>描述...</dd>
        </dl>

(8)cite:用于表示作者。

(9)small:用于标识“小型文本”。

(10)

标签:定义外部的内容。

(11)

(12)

(13) 标签:定义图形(是为了客户端矢量图形而设计的)。

(14) 标签:定义命令按钮,比如单选按钮、复选框或按钮。

(15) 标签:定义嵌入的内容,比如插件。

(16)

 标签:定义 section 或 document 的页脚。

(17)

 标签:定义 section 或 document 的页眉。
(18)
 标签:用于对网页或区段(section)的标题进行组合。

(19)

 标签:用于对网页或区段(section)的标题进行组合。

(20)

(21) 标签:定义不同类型的输出,比如脚本的输出。

(22) 标签:在 ruby 注释中使用,以定义不支持 ruby 元素的浏览器所显示的内容。

(23) 标签:定义字符(中文注音或字符)的解释或发音。

(24) 标签:定义 ruby 注释(中文注音或字符)。

(25)

 标签:定义文档中的节(section、区段)。比如章节、页眉、页脚或文档中的其他部分。
(26) 标签:为媒介元素(比如

(27)

 标签:details 元素的标题,”details” 元素用于描述有关文档或文档片段的详细信息。”summary” 元素应该是 “details” 元素的第一个子元素。

(28)

(29)

 (30) 

标签:定义对话(会话)dialog元素表示几个人之间的对话。


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
H5: The Evolution of Web Standards and TechnologiesH5: The Evolution of Web Standards and TechnologiesApr 15, 2025 am 12:12 AM

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

Is H5 a Shorthand for HTML5? Exploring the DetailsIs H5 a Shorthand for HTML5? Exploring the DetailsApr 14, 2025 am 12:05 AM

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

H5 and HTML5: Commonly Used Terms in Web DevelopmentH5 and HTML5: Commonly Used Terms in Web DevelopmentApr 13, 2025 am 12:01 AM

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

What Does H5 Refer To? Exploring the ContextWhat Does H5 Refer To? Exploring the ContextApr 12, 2025 am 12:03 AM

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

H5: Tools, Frameworks, and Best PracticesH5: Tools, Frameworks, and Best PracticesApr 11, 2025 am 12:11 AM

The tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.

The Legacy of HTML5: Understanding H5 in the PresentThe Legacy of HTML5: Understanding H5 in the PresentApr 10, 2025 am 09:28 AM

HTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee

H5 Code: Accessibility and Semantic HTMLH5 Code: Accessibility and Semantic HTMLApr 09, 2025 am 12:05 AM

H5 improves web page accessibility and SEO effects through semantic elements and ARIA attributes. 1. Use, etc. to organize the content structure and improve SEO. 2. ARIA attributes such as aria-label enhance accessibility, and assistive technology users can use web pages smoothly.

Is h5 same as HTML5?Is h5 same as HTML5?Apr 08, 2025 am 12:16 AM

"h5" and "HTML5" are the same in most cases, but they may have different meanings in certain specific scenarios. 1. "HTML5" is a W3C-defined standard that contains new tags and APIs. 2. "h5" is usually the abbreviation of HTML5, but in mobile development, it may refer to a framework based on HTML5. Understanding these differences helps to use these terms accurately in your project.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools