Foreword
HTML 5 is like a revolution, which is going on vigorously in the post-Web2.0 era.
What HTML 5 is, I don’t need to go into details here. As for the innovation of HTML 5, according to my understanding, it can be summarized as a tag system with clear semantics, rich media support that simplifies complexity, magical local data storage technology, rich animation (canvas) that does not require plug-ins, and powerful API support. . In short, HTML 5 makes human-computer interaction more comfortable and user-friendly. The previous lack of support for rich media applications and native storage is no longer a pain point for browsers. Pushing the Web from a content platform to a standardized application platform and unifying the standards of various platform camps is the original intention of the HTML 5 revolution.
In this article, I will introduce some ideas and explain one of the innovations of HTML 5: a clearer and more concise structure with semantics.
Start with the "head"
A standard XHTML header code should be like this:
Can you remember? Will you memorize it by rote? Of course not! We just need to mechanically copy and paste.
Look at what a standard HTML 5 header looks like:
It’s more complicated than simple, I don’t need to say it. Yes, the HTML 5 header can be so simple and easy to remember! Also, case, quotes, and the backslash before the last angle bracket can be ignored.
Why can it be so loose? In fact, if you send XHTML as text/html, the browser can parse it well, and the browser does not care about the syntax of the code. Therefore, HTML 5 is metaphysical. It may break some original standards, but it can still perform well in browsers.
Of course, for the convenience of team assistance and subsequent maintenance, we should still unify a writing style that you like, such as:
...
...
In addition, although HTML 5 is not currently supported by all browsers, this can save more than 100 bytes (for sites with more than one million daily PV, it can save a lot of traffic) ) head is now perfectly compatible. If you have researched browser parsing modes, you should know that the page will trigger weird mode if doctype is not defined, but as long as is defined, the browser can parse the page in standard mode, and There is no need to specify a certain type of DTD.
New semantic tag system
Semantic coding is an essential skill for a qualified front-end developer. However, as web pages become increasingly rich, only the original xhtml tags are used to de-semantize them. It was obviously beyond his capabilities. God said: "Let there be light!" And there was light. Therefore, HTML 5 provides a series of new tags and corresponding attributes to reflect the typical semantics of modern websites. Practice the truth. Let’s write an example: