Summary of CSS Hacking Methods for Specifying the Doctype of a Web Page_Experience Exchange

WBOY
Release: 2016-05-16 12:04:30
Original
1398 people have browsed it

But in fact, there are far more than just these browsers. Firefox is divided into several major versions: Firefox 1.5, Firefox 2, and Firefox 3. IE7 and IE6 also have several series each. In addition, apart from the products of these two mainstream manufacturers, In addition, there are Opera, Konqueror, Netscape, chrome, etc.

Each of these browsers has its own set of rules. It often runs normally here and not properly there. So WD demolished the east and repaired the west, and finally it worked normally under several browsers. As a result, the product manager had new needs and needed to make changes here and there. As a result, the paper frame that had been finally fooled suddenly collapsed, and the WDs were extremely busy again. The reason why I say this is because this is my experience.

Generally, WD always collects a bunch of Css Hacking skills in order to make it work properly under various browsers. Searching online, there are a lot of them.

However, first of all, WD did not figure out a basic question, why do we need css Hacking? If there are 1,000 browsers, do we need to remember the Hack skills of 1,000 browsers?

In fact, CSS Hacking is, to some extent, something that cannot be brought to the table. There are many techniques in Css Hacking, which simply take advantage of browser bugs. For example, it is common to use _class{….} ​​to distinguish between IE and Firefox. Logically speaking, _class is an illegal tagging method. The emergence of Css Hacking is a last resort for WDs. The daily work of WDs is not crazy Css Hacking.

In fact, there are so many browsers that you can’t just mess around and define whatever you want. Define a mark. People are accustomed to living in a standard world, and in the web world, there are also a series of standards. Browsers are also working hard to be compatible with web standards. But some browsers debuted early, and it can be said that the web standards that emerged later were born under their influence. There is another person who was very good at that time, so he made a lot of innovations and didn't take web standards to heart. He didn't care. What's more, the standards themselves are constantly being updated. Therefore, generally every browser product system went through a period when they didn't care much about web standards. Later, everyone realized that it was no longer possible. We all compromised and established a set of standards that everyone would abide by. But in the past, each company had some small rules and regulations that they had formulated. What should they do if they did not meet the standards?

So, these people thought of a way: standard mode and weird mode. There is another one called "almost standard mode", almost standard. To say it is really weird, I feel dizzy. Don't worry, just listen to me slowly.

Didn’t I say that these bosses sat together and formulated various standards. In the future, everyone will interpret web pages according to this set of standards. If the web page you make can be interpreted according to this set of standards, then use a tag doctype to indicate that it can be interpreted according to web standards. This is the standard mode.

So what should I do if the Xiaojiujiu products that have been produced by various companies in the past do not meet the standards? You can't just throw them all away right away, right? There is probably a set of principles in software called backward compatibility.In weird mode, each browser simulates the operation of those older versions of the browser to prevent older pages from not working. When the web page does not specify a doctype, the browser usually works in a weird mode to prevent the old page from not working.

The most notable example of the difference between these two modes involves IE's proprietary box model on Windows. When IE 6 came out, the correct box model was used in standards mode and the old proprietary box model was used in weirdness mode. To maintain backward compatibility with IE 5 and earlier, Opera 7 and later also use the flawed IE box model in weird mode.

Mozilla and Safari also have a third mode called "almost standards mode", which is the same as standards, except for some minor differences in how tables are handled. The pattern is the same.

It is for this reason that you can throw away a lot of css hacking techniques. Some books say that the box model (or box model in some places) of IE6 and Firefox is inconsistent, so you need to do this hack:

div{
width:100px;
*width:95px ;
}

I say, this kind of book is really misleading. Because, as long as the doctype is specified correctly, these differences in browser interpretation will disappear, and we can just follow the standard.

This mode is specified by the DOCTYPE field located at the beginning of the HTML file. The most common ones are:

HTML 4.01 Transitional:

Copy code The code is as follows:




HTML 4.01 Frameset

Copy code The code is as follows:


div>

 XHTML 1.0 Strict

Copy code The code is as follows:




XHTML 1.0 Transitional

Copy code The code is as follows:



 XHTML 1.0 Frameset

Copy code The code is as follows:


div>
 XHTML 1.1

Copy code The code is as follows:



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!