When we open the source code of a regular website, we will find that the source code must start with <!DOCTYPE html at the beginning, and some of the <!DOCTYPE> are added directly after this, and some have very long texts, such as
<!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>
Of course, the more mainstream web source code, such as Ewei Technology source code, all adopts HTML5 format and directly starts with <!DOCTYPE html>. <!DOCTYPE html> Since it is not an HTML tag, it is just a browser directive that tells the browser to write the version of the tag used to write the page, so it does not need to appear in pairs. <!DOCTYPE html> is case-sensitive in any version, but it is customary to write <!DOCTYPE html>. Of course, in order to comply with the W3C standard, it is also possible to write <!doctype html>.
Ewei Technology's homepage source code uses HTML5 declaration + HTML4 compatible
DOCTYPE means document type in English, which is the version type declaration of HTML. HTML has no specifications since the beginning, and then entered the HTML5 era. The specifications in each period are different. For example, it cannot be implemented in earlier versions of HTML. This is because HTML tags must appear in pairs, so they must be represented in <br/>. This concept has been blurred in the later stages of HTML4, and it is the same whether it is with or without/end. However, in HTML 5, it is already stipulated that you do not need to bring /, just <br>.
Such a confusing explanation method requires telling the browser the version specifications used for the current HTML encoding of the web page.
It is important to specify DOCTYPE in all HTML documents so that the browser can understand the expected document type.
DOCTYPE in HTML 4.01 requires references to DTD because HTML 4.01 is based on SGML. HTML 5 is not based on SGML, so there is no need to reference DTDs, but doctype is needed to regulate browser behavior (let the browsers run the way they should.).
HTML 5 does not have any document types, but it is best to avoid using frame frameworks; XHTML 1.0 specifies three XML document types: Strict, Transitional and Frameset; HTML 4.01 specifies three document types: Strict, Transitional and Frameset.
The expression is very concise, with only one attribute: the root element is html
<!DOCTYPE html>
If you need clean markings to avoid confusion in presentation layers, use this type. Please use it with Cascading Style Sheets (CSS):
<!DOCTYPE htmlPUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
In the above declaration, the root element of the document is declared as html, which is defined in DTD with the public identifier defined as -//W3C//DTD XHTML 1.0 Strict//EN. The browser will understand how to find a DTD that matches this public identifier. If not found, the browser will use the URL after the public identifier as the location to look for the DTD.
Transitional DTD can contain rendering properties and elements that W3C expects to move into the style sheet. Use this type if your readers use browsers that do not support cascading stylesheets (CSS) so that you have to use the rendering feature of XHTML:
<!DOCTYPE htmlPUBLIC -//W3C//DTD XHTML 1.0 Transitional//ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
Use this DTD when you want to use a framework!
<!DOCTYPE htmlPUBLIC -//W3C//DTD XHTML 1.0 Frameset//ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd>
Transitional DTD can contain rendering properties and elements that W3C expects to move into the style sheet. Use this type if your readers use browsers that do not support cascading stylesheets (CSS) so that you have to use the rendering feature of HTML:
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd>
If you need clean markings to avoid confusion in presentation layers, use this type. Please use it with Cascading Style Sheets (CSS):
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd>
Frameset DTD should be used for documents with frames. Except for the frameset element that replaces the body element, Frameset DTD is equivalent to Transitional DTD:
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01 Frameset//EN http://www.w3.org/TR/html4/frameset.dtd>