Search code examples
htmlcharacter-encodingdoctypehead

HTML: How to initiate HTML document header


I am still pretty new to HTML and programming in general so this is more of a curiosity question but I am asking as I want to use it the right way.

Whenever I have to initiate an HTML document I start it as below and never observed any issues. However, when I work in Adobe Dreamweaver and create a new document there it always shows me the below initiation.

Of course I can overwrite this but I would like to know what is the difference and when it would make sense to use any of Adobe's suggested attributes or to add something else to my first four lines.

Can someone help me with this ?

My current initiation:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <!-- ... -->

HTML initiation shown in Dreamweaver:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <!-- ... -->

Many thanks in advance, Mike


Solution

  • <!DOCTYPE html>
    

    This is HTML 5. The current standard.

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    

    This is XHTML 1.0 Transitional. A standard from 2000 designed to combine the transition from HTML 3.2 (1997) to HTML 4 (1998) and XML (which never saw wide use, except while pretending to be HTML 4.


    can you explain the single attributes that are different to mine and when it would make sense to use any of them ? Esp. regarding

    "PUBLIC",

    That isn't an attribute. The PUBLIC portion of a Doctype declaration tells the client where it can download the DTD. (As opposed to the SYSTEM portion which gives it an identifier that it can use to look it up from a local catalogue).

    Browsers have never cared about DTDs.

    "xmlns",

    XML Namespace. It lets you distinguish between elements and attributes that have the same name but are from different specifications.

    "http-equiv"

    "This is equivalent to an HTTP header with this name"

    It is largely a joke. Nothing really implements this except for the character encoding portion of the content-type header and HTML 5 gives much nicer syntax for specifying that.

    "content".

    The value of the above.