Precautions for W3C strict verification in strict Mode

Source: Internet
Author: User
Tags cdata

First, let's talk about this article.ArticleIs from the jsmix article.

The title of jsmix is still in the fog."It's not a good player who won't cook fried rice.ProgramMember"Do you know this? I really don't know;

Now the text begins.

Many websites do not pay much attention to W3C
But this is not a good thing after all, some of them do not verify in order to save trouble, some do not pay attention to some issues during the development process, as a result, if you want to modify it later to pass verification, the cost will be too high.
Discard, some to saveCodeReducing traffic and speeding up loading, giving up the red tape. But in any case, at least by strictly complying with a common industry standard to regulate your code, it is also a matter of high praise.
Situation. This site declares W3C strict
And all pages are verified with zero errors and zero warnings. Below are some problems that may be less noticed and may cause errors. If you want to pass the verification, these problems should be worth noting.
A look.

1. Correctly embed flash

Many people still use the embed label to embed Flash files, even in the video sharing Code provided by Youku. This label has been deprecated and correctly embedded into Flash files, which must be used as follows:ObjectLabel, and with the param labelObjectSet parameters.

<Object type = "application/X-Shockwave-flash" width = "480" Height = "400"> <Param name = "movie" value = "flash Address"> </ param> </Object>
2. Javascript in the document

Sometimes it is inevitable to output some JavaScript code through the background. Such code can only be directly written in X (HTML)
This is not a problem, but if the JavaScript code contains HTML characters, in addition to using the correct script
In addition to the label package code, you also need to add character data, that isCDATAMark. All entity characters under this mark are treated as character data in HTML.

 
// Correct syntax <SCRIPT type = "text/JavaScript"> // <! [CDATA [Var DIV = '<div> </div> '; //]> </SCRIPT> // incorrect syntax <SCRIPT type = "text/JavaScript"> var DIV = '<div> </div> '; </SCRIPT>

3. Code pasting

A developer's blog generally has some instance code, but these codes often contain characters with special meanings for HTML, such<And>The start and end signs of an HTML Tag respectively. In this case, the object name or object number of this character must be used. For example<For example,The object name is& Lt;, Entity encoding is& #60;.To learn more about HTML Entity, go to w3school.

4. Target = "_ blank"

You no longer need to use this attribute on tag a to open the page in a new window, so that you can freely choose to put it. They can click in the middle of the mouse or press Ctrl
Click the link to easily achieve the same purpose. If you need to force the user to open the link in a new window, add the tagRel = "external"And then use the following
JavaScript code:

 
VaR anchors = document. getelementsbytagname ("A"); For (VAR I = 0; I <anchors. length; I ++) {If (ANCHOR [I]. getattribute ("rel") = "external") {anchorpolici2.16.tar get = "_ blank ";}}

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.