HTML5 learning notes (1): HTML5 introduction and syntax, html5 learning notes

Source: Internet
Author: User

HTML5 learning notes (1): HTML5 introduction and syntax, html5 learning notes
HTML5 Introduction

HTML5 is the next-generation HTML standard specification after HTML4. It provides some new elements and attributes (such<nav>Website navigation blocks and<footer>). The new tags facilitate search engines and semantic analysis, and help small screen devices and People with Visual Impairment better. In addition, they also provide some new functions, such as video and audio<video>And<audio>To sum up, there are the following features:

  • Removed some outdated element and attribute tags in html4.

These include purely display effect tags, such<font>And<center>They have been replaced by CSS. HTML5 draws some suggestions from XHTML2, including some functions used to improve the document structure, such as the new HTML Tagheader,footer,dialog,aside,figureSuchdiv.

  • Separation of content and presentation

bAndiLabels are retained, but they have different meanings. These labels are used only to mark a text segment, rather than to set a bold or italic style for them.u,font,center,strikeThese labels are completely removed.

  • Add some new form input objects

Including date, URL, and Email address. Other objects are supported for non-Latin characters. HTML5 also introduces micro-data. This method uses tags that can be recognized by machines to label content, making Semantic Web processing easier. In general, these structure-related improvements allow content creators to create more clean and easier-to-manage webpages. Such webpages are more friendly to search engines and read screen software.

  • Brand new and more reasonable labels

No more multimedia objects will be boundobjectOrembedTag, but the video has the video Tag, and the audio has the audio Tag.

  • Local Storage

This function is embedded with a local SQL database to accelerate interactive search, cache, and indexing. At the same time, those offline Web programs will also benefit a lot. You do not need rich animations for plug-ins.

  • Canvas object

This will give the browser the ability to draw vector images directly above, which means that users can directly display graphics or animations in the browser without using Flash and Silverlight.

  • New API extensions

IsHTMLDocumentAndHTMLElementNew API extensions are provided as an excuse.

  • HTML5 replaces Flash and Silverlight
Syntax (Syntax) 1 file media type

Most HTML syntaxes defined by HTML5 are compatible with HTML4 and XHTML1, but some of them are not compatible. Most HTML documents are saved as text/html media types.

HTML5 defines detailed parsing rules (including error handling) for HTML syntax. You must follow these rules to save them as text/html media types. The following is an example that complies with HTML syntax specifications:

<!doctype html>

 

HTML5 also defines a text/HTML-sandboxed media type for the html syntax, so that the host does not trust the content.

Other syntaxes that can be used in HTML5 are XML, which is compatible with xhtml1. To use the XML syntax, you need to save the document as an XML media type, and set the namespace to http://www.w3.org/5o/xhtmlaccording to XML specifications.

The following example documents comply with the XML syntax specifications in HTML5. Note that XML documents must be saved as XML media types, such as application/xhtml + xml or application/xml.

<?xml version="1.0" encoding="UTF-8"?>

 

2 Character Encoding

In the HTML Syntax of HTML5, there are three forms to declare the encoding type of the string:

  1. On the transport level, set Content-Type in the header of the HTTP instance.
  2. Set a Unicode Byte Order Mark (BOM) at the beginning of the file. This character provides a signature for the file's encoding mode.
  3. In the content before the first 1024 bytes of the document, use the meta element with the charset attribute to declare the encoding method. For example, <meta charset = "UTF-8"> indicates that the document is in UTF-8 format. It replaces the original <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"> syntax declaration, although the original syntax is still available, but it is not recommended in HTML5.

The XML syntax in HTML5 is still the same as the previous XML syntax declaration.

3 DOCTYPE

HTML Syntax of HTML5 requires that the document declare DOCTYPE to ensure that the browser can display the page in standard mode. This DOCTYPE has no other purpose and is optional in XML, because documents in XML media format are always processed in standard mode.

The DOCTYPE declaration method is <! DOCTYPE html>, case insensitive. The DOCTYPE declared in earlier versions of HTML takes a long time because the HTML language is based on SGML and therefore needs to reference a corresponding DTD. HTML5 is different from the previous version. You only need to declare DOCTYPE to tell the document to enable the HTML5 syntax standard. The browser will <! DOCTYPE html> to do the rest of the work.

4 MathML and SVG

HTML5 HTML syntax allows you to use MathML (Mathematical Markup Language) and SVG (scalable vector graph) elements in your documents. For example, a very simple HTML page contains a circle drawn by an svg element:

<!doctype html><title>SVG in text/html</title><p> A green circle: <svg> <circle r="50" cx="50" cy="50" fill="green"/> </svg></p>

 

More complex combined tags are also supported. For example, you can use the foreignObject element of svg to nest MathML, HTML, or itself.

5 others

HTML5 is already native to support Siri, although these Siri can only be used in documents of UTF-8 and UTF-16.

If the lang attribute is set incorrectly, it will be updated to a null string to tell the browser that it is an unknown language, which serves the same purpose as XML: lang in xml.

Copyright statement: This article is the original author of the http://www.zuiniusn.com, not allowed by the blogger can not be reproduced.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.