Simple HTML5 beginners and html5 beginners
This article mainly introduces a simple HTML5 getting started tutorial. For some static text display methods, you can refer
HTML5 represents the future. W3C (World Wide Web Consortium) has abandoned XHTML, making HTML5 a standard and recognized.
HTML5 is the next generation of HTML.
HTML5 will become a new standard for HTML, XHTML, and html dom, with the goal of replacing the existing HTML4.01 and XHTML1.0 standards. It is expected to reduce the dependency of Internet rich applications (RIA) on Flash, Silverlight, JavaFX, etc.
And more APIs that can effectively enhance network applications.
The previous version of HTML was born in 1999. Since then, the Web world has undergone great changes.
HTML5 is still in progress. However, most modern browsers already have some HTML5 support.
HTML5 is the result of W3C cooperation with WHATWG.
WHATWG focuses on web forms and applications, while W3C focuses on XHTML 2.0. On April 9, 2006, the two sides decided to cooperate to create a new version of HTML.
Rules for HTML5:
The new features should be based on HTML, CSS, DOM, and JavaScript.
Reduce the need for external plug-ins (such as Flash)
Better error handling
More replace script Markup
HTML5 should be independent of devices
Development process should be transparent to the public
Simplest HTML5 document
Copy XML/HTML Code to clipboard
- <! Doctype html>
- <Title> A Tiny HTML Document </title>
- <P> Let's rock the browser, HTML5 style. </p>
A simple HTML5 document that contains only one line of text. Its effect in the browser is as follows:
More common structures are segmented using Copy XML/HTML Code to clipboard
- <! Doctype html>
- <Html>
- <Head>
- <Title> A Tiny HTML Document </title>
- </Head>
- <Body>
- <P> Let's rock the browser, HTML5 style. </p>
- </Body>
- </Html>
<Html>,
HTML5 Document Type
Copy XML/HTML Code to clipboard
- <! Doctype html>
The first line must be a specific document type declaration, which is used to indicate the standards followed by the document tag. HTML5 document type declaration is extremely simple.
Character encoding
Most websites now use UTF-8 encoding, Which is concise, fast to convert, and supports any non-English character you want.
It is easy to add the character encoding information in HTML5. Add the <meta> element in Copy XML/HTML Code to clipboard
- <Head>
- <Meta charset = "UTF-8">
- <Title> A Tiny HTML Document </title>
- </Head>
The Dreamweaver design tool automatically adds this metadata when creating a new webpage, and saves the file as UTF Encoding format. If you are using the simplest text editor, remember to select the correct encoding (UTF-8) when saving ).
Page Language
It is a good habit to specify the natural language used on a webpage. To specify a language for the content, you can use the lang attribute on any element.
The following code adds a language description for the entire page to specify the lang attribute for the Copy XML/HTML Code to clipboard
- <Html lang = "zh-CN">
If the page contains text in multiple languages, this information details are also useful for screen readers.
Add a style sheet
As long as it is a specially designed professional website, it will definitely use the style sheet. When specifying the CSS style sheet to be used, you need to add the <link> element in Copy XML/HTML Code to clipboard
- <Head>
- <Meta charset = "UTF-8">
- <Title> A Tiny HTML Document </title>
- <Link rel = "stylesheet" href = "TinyHTML5.css">
- </Head>
Add JavaScript
Adding JavaScript in HTML5 is similar to adding JavaScript on a traditional page, for example:
Copy XML/HTML Code to clipboard
- <Head>
- <Meta charset = "UTF-8">
- <Title> A Tiny HTML Document </title>
- <Link rel = "stylesheet" href = "TinyHTML5.css">
- <Script src = "TinyHTML5.js"> </script>
- </Head>
You do not need to add the language = "JavaScript" attribute. The browser assumes that you want to use JavaScript.
Note:
If you want to spend a lot of time in IE testing pages containing JavaScript, you should also add a special comment called the Web sign (saved from url = ), this line of comment should be placed behind the specified character encoding element, as follows:
Copy XML/HTML Code to clipboard
- <Head>
- <Meta charset = "UTF-8">
- <! -- Save from url = (0014) about: internet -->
- <Title> A Tiny HTML Document </title>
This comment tells IE to view the page as downloaded from a remote website. Otherwise, IE switches to a special lock mode and a security warning is displayed, the JavaScript code is executed only after you click the "allow blocked content" button.
(0014) indicates the length of an internet string.
Final Result
A complete and beautiful HTML5 code is eventually as follows:
Copy XML/HTML Code to clipboard
- <! Doctype html>
- <Html lang = "zh-CN">
- <Head>
- <Meta charset = "UTF-8">
- <! -- Save from url = (0014) about: internet -->
- <Title> A Tiny HTML Document </title>
- <Link rel = "stylesheet" href = "TinyHTML5.css">
- <Script src = "TinyHTML5.js"> </script>
- </Head>
- <Body>
- <P> Let's rock the browser, HTML5 style. </p>
- </Body>
- </Html>