HTML Overview:
HTML is an abbreviation for the English Hyper Text mark-up Language (Hypertext Markup Language), which is a standard language (tag) for making Web pages. The equivalent of a uniform set of rules, everyone to abide by him, so that you can let the browser according to the rules of the markup language to explain it. The browser is responsible for translating the label into a user "readable" format, presented to the user! (Example: Djangomoan template engine)
HTML Document
The basic code is as follows:
<!DOCTYPE HTML><HTMLLang= "en"><Head> <MetaCharSet= "UTF-8"> <title>Title</title></Head><Body></Body></HTML>
Document Tree
Doctype
DOCTYPE tells the browser what HTML or XHTML specification to use to parse an HTML document
The difference between having and not
- Backcompat: Standard compatibility mode is not turned on (or is called "weird" mode [Quirks modes], promiscuous mode)
- Css1compat: Standard compatibility mode is turned on (or called strict mode [standards Mode/strict mode])
This property will be recognized and used by the browser, but if your page does not have a DOCTYPE declaration, then compatmode default is Backcompat, which is the beginning of the devil-the browser in its own way to parse the rendered page, then the different browsers will show different styles. If your page is added, then it is equivalent to opening the standard mode, then the browser will have to honestly interpret the rendering page according to the standards of the Web, so that your page in all browsers will display a look.
What's the use?
DOCTYPE tells the browser what HTML or XHTML specifications are used to parse the HTML document, and the DTD file contains tags, attributes, properties, and constraint rules.
The problem arises:
When Netscape4 (the early browser of Netscape) and IE4 (Microsoft's early browser) implemented the CSS mechanism, it did not follow the standards presented by the Web-company. Netscape4 provided poor support, while IE4, though close to the standard, still failed to fully correct the standard of support. Although IE 5 fixes many of the IE4 problems (bugs), it still continues with other failures in the CSS implementation (mainly the box model).
To ensure that their websites are displayed correctly in different browsers, Web developers have to use CSS based on the specifications of each browser. As a result, most Web sites do not conform to the CSS implementation standards.
However, as standard consistency becomes more important, browser developers have to face a difficult choice: the standard of gradual follow-up is the way forward. But changing the implementation of the existing CSS, complete to follow the standard, will make many sites more or less damaged. If the browser suddenly resolves the existing CSS in the correct way, the stale site display will inevitably be affected.
As a result, it can be problematic to follow standards immediately, while ignoring the standards will keep the chaos of the browser war (a race between Microsoft and Netscape)
Solution:
- Allow Web developers to choose the patterns they know.
- Stale Web sites are still displayed using legacy rules.
In other words, all browsers need to provide two modes: quirks mode (i.e. compatibility mode) serves legacy rules, and strict mode serves Standard rules. The Mac platform's IE browser is the first to implement these two modes, Mozilla, Safari, Opera and Windows platform IE6 also successively implemented these two modes. The IE5 and Netscape4 of the Windows platform provide only weird patterns.
Choosing which mode to use requires a trigger, and "Doctyp toggle" is used for this purpose. According to the standard: any one (x) HTML document must have a DOCTYPE: DTD (document type definition) is a set of machine-readable rules that indicate what is allowed in the (x) HTML document, what is not allowed, and what DOCTYPE is used to tell the browser which DTD to use, Usually put in the (X) HTML document at the beginning of the declaration) to tell other people the type of the document style
- The Web page that arose before the tide of standardization did not have a DOCTYPE statement. So ' no doctype ' means triggering a weird pattern: rendering Web pages based on legacy CSS rules.
- Conversely, if the developer is explicitly aware of the inclusion of DOCTYPE, they should understand what they want to do. As a result, most DOCTYPE declarations will trigger strict patterns: rendering Web pages based on standard CSS rules.
- Any new or unknown DOCTYPE will trigger strict mode.
- Some pages are written according to the quirks mode, but contain DOCTYPE. In this case, each browser triggers the quirks mode according to its own list of DOCTYPE rules, comparing the chart with the following browser
Head part
1. Meta (metadata information)
Provides meta-information about pages, such as page encodings, refreshes, jumps, descriptions and keywords for search engines and update frequency
1. Page encoding
<meta charset= "UTF-8" > #指定编码类型为UTF-8
2. Refresh and jump
<meta http-equiv= "Refresh" content= "5" > #指定每5秒刷新一次
<meta http-equiv= "Refresh" content= "1; url=http://www.cnblogs.com/luotianshuai/"/> #指定1秒之后跳转页面至另一个网页
3. Key words
The role of keywords: general is to let the crawler such as the collection program, when they crawl your site, if you have keywords, then they will prioritize the keywords into their records, such as Baidu: if they are included, they search your keywords, you can find our site.
<name= "keywords" content= "Developer, blog Park, developer, program Ape, Cheng, geek, programming, code, open source, it website, Developer,programmer,coder,geek, Technical community ">
4. Description
Cnblog, for example, is a description:
<name= "description" content= "Blog Park is a knowledge-sharing community for developers. Since its inception, the blog Park has been dedicated and focused on creating a pure technology exchange community for developers, driving and helping developers to share knowledge through the Internet, which will benefit more developers. The mission of the blog Park is to help developers change the world with code. ">
5, X-ua-compatible
X-ua-compatible This is IE8 unique, know can, because the front-end students are very afraid of IE because they are more than the issue of various versions of the problem is very strange, when the IE8 Microsoft wants to unify the various versions, then this parameter appears, he in order to backward compatibility, The following code will run in IE7 mode if IE8 is used.
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
2. Title
Page header information, as shown in:
3. Link
The icon for the page header
<link rel= "shortcut icon" href= "Favicon.ico" >
As follows:
Importing CSS is similar to importing a module in Python
<rel= "stylesheet" href= "Css/css_model.css">
4. Style
1. Write CSS styles in the current file
2, in other files to write CSS style similar to Python module import CSS style imported into the current file using
<type= "Text/css"> . bb{ background-color:red; < /style >
5. Script
1. Write JS in the current file
2, in other files write JS python-like module import method to import JS into the current file using
Introduction of documents < type= "Text/javascript" src= "http://www.googletagservices.com/tag/js/ Gpt.js "></> write js code < Type= "Text/javascript"></>
Body part
1, the body is divided into two categories of tags: block-level labels and inline tags, block-level labels occupy the entire line, the inline label occupies the actual size of his use such as:
Block-level tags & inline tags:
<!-- inline and block-level - < style= "background-color:red;" ></div> < style = "Background-color:green;" ></span>
2. Special handling of special symbols
For example, if <p> is a paragraph tag, what if I want to output <p> this string instead of getting the <p> style?
<div> < P > </ Div >
So special symbols have their own definitions more see connections: more
Front-end Primary (HTML&CSS)