Several solutions compatible with IE678 do not support html5 labels _ html5 tutorial tips-

Source: Internet
Author: User
The era of html5 has arrived. If you are still struggling with whether you should master html5 and css3 technologies, please stick to your mouth and study hard! Next, let's take a look at several methods that are compatible with IE678 and do not support html5 tags. The era of html5 is now popular. If you are still waiting for browser compatibility, it means you are out of touch with the web. Of course, this is due to the booming development of mobile clients. If you are still struggling with the html5 and css3 technologies, please stick to your mouth and study hard! Because the front-end spring has arrived, and there is more than one spring. If you do not believe it, I can only say: Believe it or not!
Next, let's look at a standard html5 tag structure: (I am only talking about tags here, and nothing else is involved)

The Code is as follows:






Html5















Of course, the progress of html5 tags is more intuitive in semantics. Of course, this is only Mao, one of the top five in html5's progress. Some people suggest: Do not say that html5's progress is revolutionary, but developmental! I don't disagree with this, but some aspects are indeed revolutionary. I don't want to run the question here. We just want to talk about labels.

Of course, when we are excited by such a wonderful semantic tag, we have to ask: Is IE supported? Unfortunately, the answer is no. If you are afraid of Internet Explorer, you have to endure it. (IE9 and IE10 are compatible with html5 and css3.0)
But you must be glad that there are many geniuses in your life. Someone has helped you solve this problem! Although not perfect!
Here are several solutions that are compatible with IE6 \ 7 \ 8 and do not support html5 labels:
1. javascript: document. createElenment ("......")
IE6 \ 7 \ 8 is not supported because they do not consider footer as a valid html Tag. Can we just make it into a tag? The most direct method is, of course, to create javascript: document. createElenment ("......")!

The Code is as follows:


(Function (){
Var element = ['header', 'footer ', 'Article', 'aside', 'region', 'nav', 'menu ', 'hgroup', 'details ', 'did', 'figure ', 'figcaption'],
Len = element. length;
While (len --){
Document. createElement (element [I])
}
})();


This is just a simple creation of several typical html5 tags, so that they can become tags in IE6 \ 7 \ 8.
Someone has already written a complete js file, and you only need to introduce it as follows:
There are also writing
The difference between html5shiv and html5shim is only "m" and "v". There is no other difference! Of course this is not what I said. The only difference is that "one has an m and one has a v-that's it ."
Here is a special note: it is the comment judgment unique to IE:
Lte: Short for Less than or equal to, that is, Less than or equal.
Lt: Short for Less than, that is, Less.
Gte: Short for Greater than or equal to, that is, Greater than or equal.
Gt: Short for Greater than, that is, Greater.
! : It means not equal to, which is the same as the non-equal identifier in javascript.
Although IE9 supports html5 tags, it does not fully support them. Therefore, you can also write "lte", depending on your choice!
Of course, do not forget to specify the display attribute of the new tag. In most cases, I want the tag to be block:

The Code is as follows:


Header, footer, article, aside, section, nav, menu, hgroup, details, dialog, figure, figcaption {display: block}


2. nested label Method
To put it bluntly, the semantic html5 tags are nested with available tags such as p, and then only write styles for p. I do not agree with this method. It is better to give the tag a semantic id or class!

The Code is as follows:




Content testing...



However, if such a structure is used, no defense is required.:

The Code is as follows:










3. IE condition comments

The Code is as follows:





......




Let's take a look at the comments specific to IE:
Lte: Short for Less than or equal to, that is, Less than or equal.
Lt: Short for Less than, that is, Less.
Gte: Short for Greater than or equal to, that is, Greater than or equal.
Gt: Short for Greater than, that is, Greater.
! : It means not equal to, which is the same as the non-equal identifier in javascript.
I believe everyone understands what is going on! This is a more painful way! A large amount of html code makes semantic-oriented code more messy. It is not good for style Writing.
4. Use xmlns to define the life space of the document
Xmlns is the abbreviation of XHTML namespace, also known as "namespace ". Like the DOCTYPE declaration, xmlns is also a declaration. Unlike the DOCTYPE declaration that still exists in HTML documents, xmlns does not exist in HTML documents. We usually see xmlns appear in XHTML documents.
This is the original namespace of xhtml, which has been simplified after HTML 5 ,.
The methods from Elco Klingen logs have attracted wide attention at the beginning. This technology contains a namespace in XML format and uses elements with a namespace prefix, for example:

The Code is as follows:











: The html5 prefix is not a standard method. You can also use another character instead: hl5. With a prefix, IE recognizes new elements and applies styles. In other browsers, the same elements and styles are successfully built in each browser.

This method has obvious drawbacks: you must use a namespace in XML format in HTML documents. Similarly, you also need to do this in css:

The Code is as follows:


Html5 \: section {
Display: block;
}


How is the compatibility with js? Below is a test deml

The Code is as follows:





; Html5


Script
Window. onload = function (){
Alert (document. getElementById ("test"). innerHTML + "--- id ")
Alert (document. getElementsByTagName ("section") [0]. innerHTML + "--- TagName ")
Alert (document. getElementsByTagName ("SECTION") [0]. innerHTML + "--- uppercase ")
}
Script


Content



Test results: IE6 \ 7 \ 8 passed the test, but only the id in fixfox and chrome can be obtained. Therefore, this method is also not a desirable method!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.