Document type declaration
At the top of each of your pages, you need a document declaration. Yes, it must.
If you do not specify a document type, your HTML is not legitimate HTML, and most browsers will use quirks mode to process pages, which means that the browser thinks you don't know what you are doing and handles your code the browser's own way. You can be an HTML master who is invincible on the earth, or your HTML can be flawless and CSS can be perfect, but if there is no document declaration or wrong document declaration, your web page is exactly the same as a short-sighted, one-eyed gibbon baby.
The documentation declaration for XHTML 1.0 Strict is as follows:
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
The following is the document statement of XHTML 1.1. As the latest version of XHTML, it looks more perfect, but there are still some problems. We will explain it a little later.
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>
Note that the DOCTYPE tag must be capitalized and prefixed with an English half-width exclamation mark! It is the only tag that breaks the rules and it doesn't need to be closed.
Language Statement
Even if the HTTP header or the xml:lang attribute is set in the html start tag, you must specify a primary language for the document. Although it is not necessary to deal with a legitimate XHTML document, it is also a ease of use consideration. Values are abbreviated, such as en (English, English), fr (French, French), de (German, German).
Declare a document that mainly uses English content, an example is this:
<html xmlns=http://www.w3.org/1999/xhtml xml:lang=en>
After declaring the main language, if you need to use another language, you can also use the xml:lang attribute inline (for example, <span xml:lang=de>HTML Hund</span>).
Content Type
The media type and font set of HTML documents may be specified, and can be done using HTTP headers, such as:
Content-Type: text/html; charset=UTF-8
The first part of the HTTP header (such as text/html) is the file MIME type, which allows the browser to know the media type of the file and therefore know how to deal with it. All files have MIME type. JPEG images are image/jpeg, CSS files are text/csss and HTML generally use text/html.
The second part of the HTTP header (such as the UTF-8 part) is the character set.
Perhaps the easiest way to set up an HTTP header is to use the header tag with HTTP synonyms (HTTP-equivalent) in HTML, like this:
<meta http-equiv=Content-Type content=text/html; charset=UTF-8 />
Below are commonly used document statements. In fact, dreamweaver is the default statement.
Copy the code