DOCTYPE

(Henvisende UWEM-test: 3.2_HTML_01)

Testinformasjon

Feil på grunn av

Det er funnet en ugyldig DOCTYPE-erklæring.

Dokumenttypeerklæring er ikke oppført i W3C recommended doctypes: http://www.w3.org/QA/2002/04/valid-dtd-list.html

Hvorfor dette vil være en hindring

Det finnes ikke bare én type av HTML, men flere typer som defineres i såkalte dokumenttypedefinisjoner, kortform dokumenttyper (Document Type Definitions, Doctypes). Ved å spesifisere dokumenttype, definerer du hvilken versjon av (X)HTML du anvender i ditt dokument.
Dette er svært viktig informasjon for nettlesere og andre verktøy som leser av dokumentet. Dersom dokumenttypeerklæringen ikke er korrekt, kan nettlesere være ute av stand til å presentere dokumentet på riktig måte.

For mer informasjon, se W3C doctype information: http://www.w3.org/QA/Tips/Doctype

Løsning

Bruk en av dokumenttypene som er oppført i http://www.w3.org/QA/2002/04/valid-dtd-list.html

Referanse

Henvisning til WCAG 1.0-kontrollpunkt

3.2

"Lag dokumenter som kan valideres etter formelle publiserte dokumentkodingssystemer." [Prioritet 2]
WCAG 1.0 Checkpoint 3.2

Henvisning til UWEM-test

3.2_HTML_01

Denne testen er rettet mot å undersøke at dokumentet inneholder en gyldig dokumenttypeerklæring.

Beslektede krav fra DIFI/norge.no

1.11

Er HTML korrekt kodet på nettstedet?
norge.no requirement description 1.11

Eksempler

The doctype tells the web browser what type the document is and what set of rules to use when displaying the web page. The doctype is also needed to carry out checks of the formal grammar of the document contents.

If the doctype declaration of your document is missing or invalid, you have to find out, which document type the document uses, and insert an appropriate recommended doctype declaration.

You can find out, which specific HTML or XHTML has been used, by looking at the tags and header informations of the document.
If empty tags are open, HTML is used; else the document uses XHTML. If the content type is "application/xhtml+xml" the language is XHTML 1.1; else XHTML 1.0.

  • HTML 4.01

    In the following example the doctype is not specified correctly.
    According to the style of the meta and the line-brake tags, the language of the document is HTML, so we decide to use the HTML 4.01 Transitional doctype.

    Dårlig eksempel:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Page with invalid doctype declaration</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- ... other header information ... -->
    </head>
    <body>
    This is the content of the page.<br>
    From the style of the tags it can be followed, that the used language is HTML.
    </body>
    </html>
    Godt eksempel:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

    <html>
    <head>
    <title>Page with valid HTML 4.01 doctype</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- ... other header information ... -->
    </head>
    <body>
    This is the content of the page.<br>
    From the style of the tags it can be followed, that the used language is HTML.
    </body>
    </html>
    Spørsmål, forslag, innvendinger? Gi oss en tilbakemelding!
  • XHTML 1.0

    In the following example the doctype is not specified correctly.
    According to the style of the meta and the line-brake tags (the tags are closed), the language of the document is XHTML. Because the content type is "text/html", the language must be XHTML 1.0, so we decide to use the XHTML 1.0 Transitional doctype.

    Dårlig eksempel:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
    <html>
    <head>
    <title>Page with incomplete doctype declaration</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <!-- ... other header information ... -->
    </head>
    <body>
    This is the content of the page.<br />
    From the style of the tags it can be followed, that the used language is XHTML.
    </body>
    </html>
    Godt eksempel:
    <!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>
    <title>Page with valid XHTML 1.0 doctype</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <!-- ... other header information ... -->
    </head>
    <body>
    This is the content of the page.<br />
    From the style of the tags it can be followed, that the used language is XHTML.
    </body>
    </html>
    Spørsmål, forslag, innvendinger? Gi oss en tilbakemelding!
  • XHTML 1.0 Frameset

    In the following example the doctype is not specified.
    According to the style of the frame tag (the tags are closed), the language of the document is XHTML. In the code we see, that this page specifies a frameset, so we decide to use the XHTML 1.0 Frameset doctype which uses the "text/html" content-type.
    The good example has also been expanded by titles for the frames and a noframes-section for accessibility.

    Dårlig eksempel:
     
    <html>
    <head>
    <title>Frameset without doctype declaration</title>
    </head>
     
    <frameset cols="20%, *">
    <frame src="navi.html" />
    <frame src="main.html" />
    </frameset>
     
    </html>
    Godt eksempel:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>XHTML frameset with valid doctype declaration</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    </head>

    <frameset cols="20%, *">
     
    <frame title="Navigation" src="navi.html" />
    <frame title="Main Content" src="main.html" />
     
    <noframes>
    <body>
    Alternative information for accessibility purposes.
    </body>
    </noframes>
    </frameset>
    </html>
    Spørsmål, forslag, innvendinger? Gi oss en tilbakemelding!
  • XHTML 1.1

    In the following example the doctype is not specified correctly.
    According to the style of the meta and the line-brake tags (the tags are closed), the language of the document is XHTML. Because the content type is "application/xhtml+xml", the language must be XHTML 1.1.

    Dårlig eksempel:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML">
    <html>
    <head>
    <title>Page with incomplete doctype declaration</title>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    <!-- ... other header information ... -->
    </head>
    <body>
    <p>
    This is the content of the page.<br />
    From the style of the tags it can be followed, that the used language is XHTML.
    </p>
    </body>
    </html>
    Godt eksempel:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Page with valid XHTML 1.0 doctype</title>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
    <!-- ... other header information ... -->
    </head>
    <body>
    <p>
    This is the content of the page.<br />
    From the style of the tags it can be followed, that the used language is XHTML.
    </p>
    </body>
    </html>
    Spørsmål, forslag, innvendinger? Gi oss en tilbakemelding!
Spørsmål, forslag, innvendinger? Gi oss en tilbakemelding!