Today, I started a brand new HTML5 series of courses. I took notes on reading the definitive guide to HTML5. I will sort out the chapters that I think are good or meaningful for you to learn.
An element can define its own attributes, such as the href attribute defined by tag ). Correspondingly, we can use global attribute to set a common behavior for all elements. Of course, you can also set global attributes for individual elements, but this does not make much sense. The following describes these global attributes one by one.
The following example runs normally in the Chrome browser. Some examples cannot run in Firefox, and I have not tested other browsers. Therefore, we recommend that you use chrome as your preferred HTML5 browser. I did not focus on browser compatibility, but on learning and implementation. HTML5 is still being improved. With its popularity, I believe that mainstream browsers will provide better support for it, and browser compatibility will be much better at that time.
1. accesskey
The accesskey attribute allows you to set one or more keyboard shortcuts so that you can select the elements on the page. Let's look at the following example:
<!DOCTYPE HTML>
In this example, you can use the combination key to select elements on the page. For example, in Windows, you can use Alt + XXX to select an element.
Running effect:
2. Class
I don't want to say anything about this attribute. It is a grouping function for elements. It is more often used in combination with CSS to set different display effects for different groups of elements.
3. contenteditable
This is a new attribute added to HTML5. Add the contenteditable attribute to the HTML element and set it to true to allow the user to edit the element content. Set it to false to prevent the user from editing.
<!DOCTYPE HTML>
4. contextmenu
The contextmenu allows you to set the right-click menu of HTML elements. When a user triggers the menu, it will pop up. So far, no browser supports this attribute.
5. dir
The dir attribute defines the alignment of HTML element text. Two values are supported: LTR (from left to right) and RTL (from right to left ).
<!DOCTYPE HTML>
6. draggable
Draggable is the attribute for implementing the drag-and-drop function of HTML elements in HTML5. We will introduce it in detail in subsequent courses.
7. dropzone
Dropzone is also an attribute for HTML element drag-and-drop in HTML5. We will introduce it in detail in subsequent courses.
8. Hidden
Everyone should be familiar with this attribute, that is, hiding an HTML element.
9. ID
This attribute should be known to all. It sets a unique identifier for the HTML element, and the element with a considerable ID is not allowed in an HTML page.
10. Lang
Lang specifies the language used by the HTML element content. The Lang value must be a valid ISO language code. For more information, visit the following url: http://tools.ietf.org/html/bcp47. It should be noted that the processing language is quite complex and technical.
<!DOCTYPE HTML>
11. spellcheck
When the spellcheck attribute is used, the browser will help you check whether the text of the HTML element is correctly spelled. the spellcheck attribute makes sense only when the HTML element can be edited.
<!DOCTYPE HTML>
Effect: (I didn't run the desired effect using chrome. I don't know why)
12. Style
This attribute does not need to be described too much. You can set CSS styles for HTML elements.
13. tabindex
Tabindex allows you to define the access sequence when HTML elements use the tab key. When tabindex is set to-1, the HTML element is not selected using the tab key.
<!DOCTYPE HTML>
Effect:
14. Title
Title can provide additional information for HTML elements, which is often used to display prompt information.
<!DOCTYPE HTML>
Effect:
This is the end of today's course. I hope this content will help you.
Demo: html5guide.rar