Concise version of HTML5 study notes (7): New attributes (2)

黄舟
Release: 2017-01-21 16:58:02
Original
1998 people have browsed it

dirname attribute

The input and textarea elements have a new element dirname, which is used to control the directionality of submission set by the user (annotation, that is, the directionality of writing, ltr or rtl).

Copy after login

When the user submits, the browser will receive three parameters: comment, comment.dir and mode, similar to the following: comment=Hello&comment.dir=ltr&mode=add

If it is an Arabic browser and the input is Arabic مرحبًا, the parameters returned should be like this:

comment=%D9%85%D8%B1%D8%AD%D8%A8%D9%8B%D8%A7&comment.dir=rtl&mode=add
Copy after login

maxlength and wrap attributes under textarea

The new maxlength of textarea is the same as the maxlength of input, both limiting the maximum length.

The newly added wrap attribute is an enumeration value (soft/hard), which means:

hard: automatic hard return and line feed, and the line feed mark is sent to the server together. It must Use it together with cols to determine how many characters are required to wrap;

soft: automatic soft carriage return and newline, the newline mark will not be sent to the server

novalidate attribute under form

The new attribute novalidate means that the form can be submitted without verification (regardless of whether the elements in the form have verification conditions, such as required, min, max, etc.).

Example code:

E-mail:
Copy after login

Another usage is that if there are multiple submit buttons in the same form, you can set the formnovalidate attribute for a certain button to ignore verification, for example:

Copy after login

This form is only verified when the Submit essay button is clicked, and the other two buttons are not verified.

New attributes under input and button

The input and button elements have added several new attributes (formaction, formenctype, formmethod, formnovalidate and formtarget). If these attributes are set, then The corresponding form attribute value will be overwritten, that is, the action, enctype, method, novalidate and target attribute values of the form element to which the input or button belongs will be overwritten.

Example code:

First name:
Last name:
First name:
Last name:

First name:
Last name:
Copy after login

Type and label attributes under menu

The menu element has two new attributes: type and label. They allow the element to be transformed into a menu in a typical user interface and provide a context menu in conjunction with the global contextmenu property.

scoped attribute under style

The style element has a new scoped attribute, which is used to enable scoped style sheets. Style rules in such a style element apply only to the subtree, or sibling tree, of the current style element's parent element.

 

Blah Title Blah

Blah blah article blah blah.

Blah Title Blah

Blah blah article blah blah.

Copy after login

The async attribute under script

The async attribute allows the script loading steps to be executed asynchronously (that is, it must be in the form of a src reference file), for example:

Copy after login


有多种执行外部脚本的方法:

如果 async="async":脚本相对于页面的其余部分异步执行(当页面继续进行解析时,脚本将被执行)

如果不使用 async 且 defer="defer":脚本将在页面完成解析时执行

如果既不使用 async 也不使用 defer:在浏览器继续解析页面之前,立即读取并执行脚本

html下的manifest属性

html 元素有了一个新属性 manifest,指向一个用于结合离线Web应用API的应用程序缓存清单。

首先,需要先创建manifest文件

CACHE MANIFEST #This is a comment CACHE #需要缓存的文件 index.html style.css NETWORK: #不需要缓存的文件 search.php login.php FALLBACK: #资源不可用的情况下,重定向的地址 /api offline.html
Copy after login

然后加该文的地址加到html属性里:


        
Copy after login

例子:http://www.mangguo.org/create-offline-html5-web-apps-in-5-easy-steps/

link下的sizes属性

link 元素有了一个新的属性 sizes。可以结合 icon 的关系(通过设置 rel 属性,可被用于如网站图示)一起使用来表明被引用图标的大小。因此允许了不同的尺寸的图标。

例子代码:

Copy after login


ol下的reversed属性

ol 元素有了一个新属性 reversed。当其存在时,代表列表中的顺序为降序。

iframe下的sanddbox, seamless和srcdoc属性

iframe 元素有了三个新属性分别是 sandbox, seamless, 和 srcdoc,用以允许沙箱内容,例如,博客评论。

例子代码:

 
Copy after login


Seamless:

Copy after login

video和audio的play属性

HTML5也使得所有来自HTML4的事件处理属性(那些形如 onevent-name 的属性)变成全局属性,并为其定义的新的事件添加了几个新的事件处理属性。比如,媒体元素(video 和 audio)API所使用的 play 事件。

The above is the concise version of HTML5 study notes (7): the content of new attributes (2). For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!