What is the correct way to declare an HTML5 Doctype.

前端 未结 10 1892
一整个雨季
一整个雨季 2020-12-30 18:48

What is the correct way to use start tag when creating with HTML5

IE: HTML 4 Strict is like this



        
相关标签:
10条回答
  • 2020-12-30 19:04

    You use...

    <!DOCTYPE html> 
    

    followed by your HTML tag etc..

    0 讨论(0)
  • 2020-12-30 19:05
    <!-- simplified doctype works for all previous versions of HTML as well -->
    <!doctype html>
    

    Learning Resource:

    • http://diveintohtml5.info/
    • http://www.html5doctor.com
    0 讨论(0)
  • 2020-12-30 19:11

    The standard has been simplified because the previous doctypes were too cryptic. The new doctype is simply <!DOCTYPE html> . You may wonder why it is not <!DOCTYPE html5> but it is simply because it is just an update to the standard of HTML and not a new version of anything. As you can see below, all elements can now have a language attribute.

    The <html> element is the root element of a document. Every document must begin with this element, and it must contain both the <head> and <body> elements.

    It is considered good practice to specify the primary language of the document on this element using the lang attribute.

    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="utf-8">
            <title>Hello World</title>
        </head>
        <body>
            <h1>Hello World</h1>
            <p>
                Jamie was here.
            </p>
        </body>
    </html>
    

    More info: https://dev.w3.org/html5/html-author/#doctype-declaration

    0 讨论(0)
  • 2020-12-30 19:18

    According to the WWW Consortium, the organization responsible setting current web standards, no one has answered this correctly. The current standard for language declaration is

    Always use a language attribute on the html tag to declare the default language of the text in the page. When the page contains content in another language, add a language attribute to an element surrounding that content. Use the lang attribute for pages served as HTML, and the xml:lang attribute for pages served as XML. For XHTML 1.x and HTML5 polyglot documents, use both together.
    W3C HTML Language Tag Page

    Here is the answer regarding DOCTYPE declaration

    Use the following markup as a template to create a new HTML document using a proper Doctype declaration. See the list below if you wish to use another DTD.
    W3C DOCTYPE Standards

    <!DOCTYPE html>
    <html>
    
    <head>
        <title>An HTML standard template</title>
        <meta charset="utf-8"  />
    </head>
    
    <body>
         <p>… Your HTML content here …</p>
    </body>
    </html>
    

    Hope this helps.

    0 讨论(0)
提交回复
热议问题