About HTML 5, HTML

Source: Internet
Author: User

About HTML 5, HTML

1. Avoid unnecessary complexity.

For example, if you create an html page before, you must write an image at the beginning.

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Or <! DOCTYPE html PUBLIC "-// W3C/dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd">.

For html 5, <! DOCTYPE html>.

The reason is that Doctype is written to the validators. That is to say, to write the line of doctype of XHTML 1.0 at the beginning of the document, it is to tell the validators to verify my document according to the doctype. However, according to another design principle of HTML 5, it must be forward and backward compatible with future HTML versions-whether HTML6, HTML7, or anything else-and the current HTML version, HTML 5, compatible. Therefore, putting a version number in the doctype does not make much sense, even if it is the same for the validator.

For example, <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> in html 5, you can write <meta charset = "UTF-8">

2. Support existing content

For example, in html5, attribute values can be enclosed by quotation marks, but also by quotation marks. The following statements are correct:

  • <P class = "foo"> Hello world </p>
  • <P class = "foo"> Hello world
  • <P class = "foo"> Hello world </P>
  • <P class = foo> Hello world </p>

Iii. solving practical problems

Another design principle of HTML 5 is to solve practical problems. Obviously, the formats and specifications for solving various problems are everywhere. Therefore, in my opinion, this principle is actually to solve theoretical problems, rather than solving practical problems. This design principle is to theoretically recognize common problems and eliminate sensitive problems.

For example, if a piece of content already exists in the page, I want to add a link to the entire content. The content includes a title and a paragraph.

Previous practices:

  • <H2> <a href = "/path/to/resource"> Headline text </a>
  • <P> <a href = "/path/to/resource"> Paragraph text. </a> </p>

Now:

  • <A href = "/path/to/resource">
  • <H2> Headline text
  • <P> Paragraph text. </p>
  • </A>

4. Be realistic and pragmatic

The meaning of truth-seeking and pragmatism for HTML is: Before solving those headaches, Let's first look at how people have come up with solutions to these problems. It is imperative to concentrate on understanding these "private" solutions.

The new semantic element in HTML 5 is a reflection of the principle of seeking truth and being pragmatic. There are not many new elements, but it is a good thing to talk about unlimited scalability. Although there are only a few, the meaning is extraordinary. These new elements involve header, footer, section, and article )......, I believe everyone will not feel unfamiliar.

Example: Previous documents:

  • <Body>
  • <Div id = "header">... </div>
  • <Div id = "navigation">... </div>
  • <Div id = "main">... </div>
  • <Div id = "sidebar">... </div>
  • <Div id = "footer">... </div>
  • </Body>

Now you can change it:

  • <Body>
  • <Header>...
  • <Nav>... </nav>
  • <Div id = "main">... </div>
  • <Aside>... </aside>
  • <Footer>... </footer>
  • </Body>

5. Stable degradation

For example, if HTML 5 follows this principle, the type attribute is used to enhance the form. The following lists the new values that can be specified for the type attribute, including number, search, range, and so on.

The most critical issue is how the browser will handle these new type values. Existing browsers, not future browsers, cannot understand these new type values. However, when they see type values that they do not understand, they will interpret the value of type as text.

6. end users are given priority

This design principle is essentially a mechanism for resolving conflicts.

In the event of a conflict, end users are given priority, followed by authors, followed by implementers, followed by standard makers, and finally theoretically complete.

7. Only designed for 80%

This is a common design principle and a general model, that is, the principle

He proposed this ratio, which is 80/20, which means that 20% of the world's population has 80% of the wealth. This proportion is a combination of power laws in various fields of nature. In short, whether you write software or make anything, it is the same, that is, 20% of the effort can touch 80% of the use cases. The last 20% cases require 80% or more effort. Therefore, sometimes it is reasonable to design only 80% based on this, because we know that we only need to make 20% effort.

8. First, design for humans, and second, design for machines.

I hope these principles will inspire everyone's software design.

Related Article

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.