- There's only one headline,
- Or
The first scenario looks like this:
- <!--Don ' t copy this code! No Need for Hgroup
- <p>by Rich clark</p>
-
In this case, the
- <p>by Rich clark</p>
-
The second case also contains tags that they do not need.
- <!--Don ' t copy this code! No need for headers here--
-
Why do we need an extra
-
Do not place all of the link lists on the <nav> tab
Of the 30 new elements added to HTML5 (as we write this article), when we build more semantically structured tags, our choices become too rich. That is to say, we are going to abuse these super-semantic tags that we now offer to us .<nav> is a very tragic example. The description in the specification is this:
The
nav element represents a, section of a page, links to other pages, or to parts within the page:a sections with Navigation links. Note:not all groups of the links on a page need to being in a nav element-the element are primarily intended for sections that consist of major navigation blocks. In particular, it's common for footers to has a short list of links to various pages of a site, such as the terms of ser Vice, the home page, and a copyright page. The footer element alone is sufficient for such cases; While a NAV element can being used in such cases, it is usually unnecessary.
WHATWG HTML Spec
The key word in this is "important" navigation. We may have different definitions of "important", but my understanding is:
- Main navigation
- Website search
- Second-level navigation (this can be controversial)
- Links within the page (e.g. a long article)
Although there is no right or wrong point, but according to my understanding and a poll made me feel that under these circumstances, I will not use the <nav> tag:
- Page
- Social links (although some social links are also the main link, like about me and taste flavours)
- Tags for blog posts
- Category List of blog posts
- Third level navigation
- Large footer
If you are not sure whether to use <nav>, then ask the following questions: "Is the person a primary link?" "You can answer the question you just made based on several factors:
- If you can solve your problem with <section> and title tags, don't use <nav>–hixie on IRC
- Are you adding a quick jump link to increase accessibility?
If the above answer is "no", it may not be appropriate to use <nav>.
Errors in <figure> elements
<figure> and often <figcaption> with it, it is difficult to grasp the label, the following is often seen some small errors.
Not all pictures are figures (note: More difficult to understand, image= pictures, figure= graphics)
Before, I once said don't write those unwanted tags. This error is also the same. I often see that every picture on a website has a <figure> tag. These additional tags will not bring you any benefits, but also add to your own intensity and make your content harder to understand.
The interpretation of <figure> in the specification is as follows: "Some stream content, which can have a title, self-contained, and usually as a unit independent of the inner document flow. "There is a perfect representation that it can be removed from the main content-for example, in the sidebar, without affecting the flow of documents."
It is not necessary to use <FIGURE> if it is just a picture of the class and does not have anything to do with the other content in the document. " Does this picture need to explain the content of the context? "If the answer is no, it may not be <figure> (probably <aside>)," Can I move it to the appendix? If the answer to both questions is yes, it could be <figure>.
Your logo is not a <figure>
Extend the above to your logo as well. Here are two sets of code snippets I've found that are regular:
- <!--Don ' t copy this code! It ' s wrong! -->
-
-
- <figure>
-
- </figure>
- My company name
-
-
- <!--Don ' t copy this code! It ' s wrong! -->
-
- <figure>
-
- </figure>
-
There is no need to say anything, this is a very obvious mistake, maybe you think we are talking about the logo in the H1 tag, but we do not discuss this issue here. What confuses us is the <figure> element. <figure> tags are used only when there is a context to explain or be surrounded by <section>. What I'm saying here is that your logo may rarely be used in this case. It's simple, so don't do it, you just need to look like this.
- <!--more stuff on here--
-
Figure can only be used on the label of misunderstanding
Another misconception about <figure> is that we generally think that it can only be used on images. In fact this is not the case, it can be used in <video><audio>, an icon (such as <svg>,), a reference, a table, a piece of code, a piece of prose, or any combination of those related. Do not confine your <figure> tags to the image alone. The task of our web-maker is to use labels to describe content more accurately.
Here is a more in-depth explanation <figure> article I wrote about <figure> it's worth reading.
Do not use those unnecessary type attributes
This may be our most common problem, they are not real mistakes, but I think our best practice is to try to avoid this pattern.
In HTML5, we do not need to add the type attribute to <script> and <script>, if it is painful to remove these from the CMS default content, Then you can delete them when you manually encode them or you can completely control your template when you write them down. Because all browsers will parse <script> into JavaScript and <css> tags are CSS, you no longer need that type attribute:
- <!--Don ' t copy this code! It ' s attribute overload! -
- <link type= "Text/css" rel= "stylesheet" href= "Css/styles.css"/>
- <script type= "Text/javascript" src= "Js/scripts.js" ></script>
Now we can write the following:
- <link rel= "stylesheet" href= "Css/styles.css"/>
- <script src= "Js/scripts.js" ></script>
You can also omit the encoding settings. Mark Pilgrim An explanation in the semantic chapter of dive into HTML5.
Do not include the wrong form properties
You may find that
Boolean property
Several of the newly introduced tag properties are Boolean, and their tag behavior is basically close. These properties include:
- Autofocus
- AutoComplete
- Required
Frankly, the following situation is not common to me, but we take the example from required as follows:
- <!--Don ' t copy this code! It ' s wrong! -
- <input type= "Email" name= "email" required= "true"/>
- <!--Another bad example--
- <input type= "Email" name= "email" required= "1"/>
Basically, this piece of code doesn't hurt. The client's parsing of the HTML will take effect when it encounters the required tag attribute. But what happens when we change the code and enter Required= "false"?
- <!--Don ' t copy this code! It ' s wrong! -
- <input type= "Email" name= "email" required= "false"/>
The required attribute is still encountered when parsing, although the behavior you wish to join is false, it will still be parsed into true.
There are three reasonable ways to get the Boolean value into effect. (The second and third option is only required when you write XHTML parsing)
Our example above can be written as follows:
- <input type= "Email" name= "email" required/>
Article from: http://www.w3cfuns.com/article-5598818-1-1.htmlCommon pitfalls of "go" HTML5 tags