Concise version of HTML5 study notes (6): New attributes (1)
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属性(不是

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.
