Home Web Front-end CSS Tutorial Summary of CSS Hacking Methods for Specifying the Doctype of a Web Page_Experience Exchange

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

May 16, 2016 pm 12:04 PM
css doctype hacking

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:



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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to view the date of bootstrap How to view the date of bootstrap Apr 07, 2025 pm 03:03 PM

Answer: You can use the date picker component of Bootstrap to view dates in the page. Steps: Introduce the Bootstrap framework. Create a date selector input box in HTML. Bootstrap will automatically add styles to the selector. Use JavaScript to get the selected date.

See all articles