DOCTYPE DECLARATION At the top of every page you write, you need a document declaration. Yes, it must. If you don't specify a document type, your HTML is not valid HTML, and most browsers will process the page in "quirks mode", which means that the browser assumes that you don't know what to do and processes your code in its own way. You can be an HTML master, unrivaled on earth, or your HTML can be flawless and your CSS can be perfect, but if there is no document declaration, or the wrong document declaration, your web page is no different from a short-sighted, one-eyed gibbon baby who put it together with great difficulty. The XHTML 1.0 Strict document declaration looks like this: <!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 declaration for XHTML 1.1. As the latest version of XHTML, it looks more perfect, but there are still some problems, which we will explain 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 preceded by an exclamation mark!. It's the only tab that breaks the rule, it doesn't need to be closed. Language Declaration Even if you set the xml:lang attribute in the HTTP header or in the HTML start tag, you must specify a primary language for the document. Although this is not necessary to process a valid XHTML document, it is a usability consideration. Values are abbreviations, such as en (English), fr (French), de (German). Declare a document with mainly English content, the example is as follows: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> After declaring the primary language, you can also use the xml:lang attribute inline if you need to use other languages (for example <span xml:lang="de">HTML Hund</span>). Content Type The media type and font set of an HTML document may need to be specified. This can be done using HTTP headers, for example: Content-Type: text/html; charset=UTF-8 The first part of the HTTP header (such as text/html) is the file's MIME type, which lets the browser know the file's media type so it can know how to handle it. All files have a MIME type. JPEG images are image/jpeg, CSS files are text/csss and HTML generally uses 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 HTTP headers is to use "HTTP-equivalent" header tags in HTML, like this: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> The following is a commonly used document declaration. In fact, Dreamweaver uses this declaration by default. Copy code The code is as follows:<!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=gb2312" /> <title>Untitled Document</title> </head> <body> </body> </html> Below is additional content from 123WORDPRESS.COM. Declaring or not declaring CSS will result in different page controls. It will not conform to w3c standards or anything. So I recommend everyone to add it. This will make your website compatible with multiple browsers. The impact of javascript will be even greater, causing previously written js codes to not run normally. Especially things like couplet advertisements. In fact, in general, you just need to pay attention to the following problem. When not declaring, generally use document.body.scrollTop; When declaring the document type, use document.documentElement.scrollTop; Here are some reference documents for writing cross-browser javascript code [js multi-browser compatible writing] There are so many convenient things about javascript firefox compatible with ie's dom method scripts, you can search for it more. |
<<: CSS3 achieves cool sliced image carousel effect
>>: Summary of MySQL Undo Log and Redo Log
Download CentOS7 The image I downloaded is CentOS...
Installation & Configuration The official web...
Composition inheritance Combination inheritance i...
1.1 Copy the nginx installation package and insta...
In this article, we would like to share with you ...
Table of contents 1. Transition from development ...
The database I use is MySQL database version 5.7 ...
This article shares the installation and configur...
This article shares the specific code for JavaScr...
Environment Preparation 1. Environment Constructi...
This article example shares the specific code of ...
1. First create the file (cd to the directory whe...
Export a single table mysqldump -u user -p dbname...
There is a requirement to realize the shaking eff...
Use self:: or __CLASS__ to get a static reference...