Media attributes under a and area
In order to maintain consistency with the link element, the a element and area element also add the media attribute, which is only valid when href exists. The media attribute means what media/device the target URL is optimized for. The default value is all. For detailed syntax specifications, please visit: http://dev.w3.org/csswg/css3-mediaqueries/#media0
Code example:
<a href="att_a_media.asp?output=print" media="print and (resolution:300dpi)"> HTML5 a media attribute. </a>
hreflang, type, rel attributes under area
In order to maintain consistency with the a element and link element, the area element adds hreflang, type, rel and other attributes.
Attribute
Value
Description
hreflang
language_code
Specifies the language of the target URL
media
media query
Specifies which media/device the target URL is optimized for
rel
alternate, author, bookmark, external, help , license, next, nofollow, noreferrer, prefetch, prev, search, sidebar, tag
Specifies the relationship between the current document and the target URL
type
mime_type
Specifies the MIME type of the target URL
The target attribute under base
The target attribute under base is the same as the target attribute of a. Many older versions of browsers have long ago Supported.
Note 1: target must be declared before all connection elements.
Note 2: If there are multiple declarations, the first one shall prevail.
<!DOCTYPE html> <html> <head> <title>This is an example for the <base> element</title> <base href="http://www.example.com/news/index.html"> </head> <body> <p>Visit the <a href="archives.html">archives</a>.</p> </body> </html>
Click on the link above to jump to http://www.example.com/news/archives.html.
The charset attribute under meta
charset is used to define the encoding method of the document. If this attribute is defined in XML, the value of charset must be case-insensitive ASCII so that match UTF-8, because XML documents are forced to use UTF-8 as the encoding method.
Note: The charset attribute on the meta attribute has no effect in XML documents. It is only for the convenience of direct migration with XHTML.
Cannot declare multiple meta elements with the charset attribute.
In HTML4, we have to define it like this:
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
In HTML5, we just define it like this:
<meta charset="ISO-8859-1">
autofocus Attribute
HTML5 adds an autofocus attribute to input, select, textarea and button elements (hidden input cannot be used), which provides a declarative way to define when the page loads From now on, focus automatically acts on the current element. Using autofocus can improve the user experience. For example, if we set it on the login page, the focus will be automatically set to the textbox of the user name after the page is loaded.
<input maxlength="256" name="loginName" value="" autofocus> <input type="submit" value="Login">
Note 1: The autofocus attribute is declared once per page.
Note 2: It is not necessary to set autofocus on a page.
placeholder属性
input和textarea元素新增加了placeholder属性,该属性是提升用户输入内容。当用户点击的时候,该内容文本自动消失,离开焦点并且值为空的话,再次显示。以前我们都是使用JavaScript代码来实现,其实蛮复杂的,有了placeholder属性就爽了,直接写成下面下这样的代码:
<input type="username" placeholder="请输入你的用户名">
form属性
form属性(不是