Add the correct DOCTYPE declaration-W3C standard for a page

Source: Internet
Author: User








Problem:



Today, we accidentally contacted placeholder the HTML5 attribute of this INPUT element. But it's strange to have the editor hint without this attribute when writing code.



Reply:



The previous HTML document stated that <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >



Change to <! DOCTYPE html>



Not bound. You can use the properties and elements of HTML.


<pre name="code" class="html">
<span style="font-size:18px;"> </span>
<span style="font-size:14px;"> 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
</span>



<! The doctype> declaration is in the front of the document, before the


eg:<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >



The above example declares that the root element of a document is Html,doctype defined in a DTD (document type definition) that is defined as a "-//W3C//DTD XHTML 1.0 strict//en" by the public identifier. The browser will look for a DTD that matches this common identifier and interpret the page code against that DTD. If the definition document is not found, the browser uses the URL following the public identifier as the address to look for the DTD.



DOCTYPE can declare three types of DTDs: strict versions (STRICT), transitional versions (transitional), and framework versions (FRAMESET).



Eg:html 4.01, XHTML 1.0






Strict DTD



Clean, free from presentation clutter, and used with cascading style sheets (CSS):



HTML 4.01:



<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01//en" "HTTP://WWW.W3.ORG/TR/HTML4/STRICT.DTD" >



XHTML 1.0:



<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >






Transitional DTD



Contains the rendering attributes and elements that the consortium expects to move into the stylesheet, which is used if a browser that does not support cascading style sheets (CSS) is used so that html/xhtml rendering attributes are used. For the general developer, if there is no special requirements for the page and want to maintain compatibility, use that type enough.



HTML 4.01:



<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >



XHTML 1.0:



<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">



Frameset DTD



For documents with frames. (In HTML 4.01, the frameset DTD is equivalent to the transitional DTD, except for the frameset element in place of the BODY element)







     <! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 frameset//en" "Http://www.w3.org/TR/html4/frameset.dtd" >
     <! DOCTYPE HTML public  "-//W3C//DTD XHTML 1.0 frameset//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >





HTML5 basically does not have XHTML 1.0 Transitional stringent requirements, and simplifies a lot of things that can be used directly <! DOCTYPE html>



HTML5:

 <! DOCTYPE html>

However, since most Web documents need to follow an internationally recognized Web standard published by the consortium, those documents typically contain one of the following standard DOCTYPE declarations:



HTML 2 (number 2 represents the version number):



<!doctype HTML PUBLIC "-/ietf/dtd HTML 2.0/en" >



HTML 3.2:



<!doctype HTML PUBLIC "-/w3c/dtd HTML 3.2 final/en" >



——————————————————————————————



HTML 4.01 Strict:



<!doctype HTML PUBLIC "-/w3c/dtd HTML 4.01/en"



"Http://www.w3.org/tr/html4/strict.dtd" >



HTML 4.01 Transitional:



<!doctype HTML PUBLIC "-/w3c/dtd HTML 4.01 transitional/en"



"Http://www.w3.org/tr/html4/loose.dtd" >



HTML 4.01 Frameset:



<!doctype HTML PUBLIC "-/w3c/dtd HTML 4.01 frameset/en"



"Http://www.w3.org/tr/html4/frameset.dtd" >



——————————————————————————————



XHTML 1.0 Strict:



<!doctype HTML PUBLIC "-/W3C/DTD XHTML 1.0 strict/en"



"Http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd" >



XHTML 1.0 Transitional:



<!doctype HTML PUBLIC "-/W3C/DTD XHTML 1.0 transitional/en"



"Http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd" >



XHTML 1.0 FRAMESET:



<!doctype HTML PUBLIC "-/W3C/DTD XHTML 1.0 frameset/en"



"Http://www.w3.org/tr/xhtml1/dtd/xhtml1-frameset.dtd" >



——————————————————————————————



XHTML 1.1:



<!doctype HTML PUBLIC "-/w3c/dtd XHTML 1.1/en"



"Http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd" >



XHTML 1.1 plus MathML plus svg:



<!doctype HTML Public



"-/W3C/DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1/en"



"Http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd" >


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.