5. Do not use unnecessary type attributes. This is a common problem, but it is not an error. I think we should avoid this style through best practices. In HTML5, the type attribute is no longer required for script and style elements. However, these are likely to be automatically added by your CMS, so you need to remove them ...,. Avoid six common HTML5 errors (5-6) 5. Do not use unnecessary type attributes
This is a common problem, but it is not a mistake. I think we should avoid this style through best practices.
In HTML5, the type attribute is no longer required for script and style elements. However, these are likely to be automatically added by your CMS, so removing them is not that easy. However, if you are manually coding or you have full control over your template, there is no reason to include the type attribute. All browsers think that scripts are javascript and styles are css. You don't have to do this any more.
View sourceprint? 1
2
3Script
In fact, you only need to write as follows:
view sourceprint?1
2 《script》
Even the code of the specified character set can be omitted. Mark Pilgrim explained in the semantic chapter of Dive into HTML5.
6. incorrect use of the form attribute
HTML5 introduces some new form attributes. The following are precautions for use:
Boolean attribute
Some multimedia elements and other elements also have a Boolean attribute. The rules mentioned here also apply.
Some new form attributes are Boolean, which means that as long as they appear in the tag, the corresponding behavior has been set. These attributes include:
Autofocus
Autocomplete
Required
Frankly speaking, I seldom see this. Taking required as an example, the following is common:
1
23
4
Strictly speaking, this is not a serious problem. As long as the browser's HTML Parser sees that the required attribute appears in the tag, its function will be applied. But what if you write equired = "false" in turn?
1
2
The parser will still regard the required attribute as valid and execute the corresponding behavior, even though you try to tell it not to execute it. This is obviously not what you want.
There are three effective ways to use the Boolean attribute. (The last two types are only valid in xthml)
Required
Required = ""
Required = "required"
The correct example is as follows:
The above is to avoid the common six HTML5 error usage (5-6) content. For more information, see PHP Chinese website (www.php1.cn )!