Use semantic tags to write your HTML compatible with IE6,7,8

Use semantic tags to write your HTML compatible with IE6,7,8

HTML5 adds more semantic tags, such as header, footer, nav, etc., so we no longer need to use the following method to layout when writing pages:

XML/HTML CodeCopy content to clipboard
  1. < div   class = "header" > This is the header </ div >   
  2. < div   class = "content" > This is the middle content area </ div >   
  3. < div   class = "footer" > This is the bottom </ div >     

And you can layout it like this:

XML/HTML CodeCopy content to clipboard
  1. <header> This is the header </header>   
  2. < content > This is the middle content area </ content >   
  3. < footer > This is the bottom </ footer >     

But IE does not support forward, so if we want to support IE6, 7, 8, we need to add a little code in js and css, as follows:

XML/HTML CodeCopy content to clipboard
  1. document.createElement("header");
  2. document.createElement("content");
  3. document.createElement("footer");

CSS:

header,content,footer{display:block}

The above means to customize a tag as header and set it to block display. The complete code is attached below:

XML/HTML CodeCopy content to clipboard
  1. <!DOCTYPE html >   
  2. < html >   
  3. < head >   
  4. < meta   charset = "utf-8" >   
  5. < title > Use semantic tags to write your HTML, compatible with IE6,7,8 </ title >   
  6. < style >   
  7. *{margin:0;padding:0;}
  8. header,content,footer{display:block}
  9. header{width:600px;height:150px;line-height:150px;border:1px solid #000;margin:10px auto;text-align:center;font-size:24px}
  10. content{width:600px;height:250px;line-height:250px;border:1px solid #000;margin:10px auto;text-align:center;font-size:24px}
  11. footer{width:600px;height:150px;line-height:150px;border:1px solid #000;margin:10px auto;text-align:center;font-size:24px}
  12. </ style >   
  13. < script   type = "text/javascript" >   
  14. document.createElement("header");
  15. document.createElement("content");
  16. document.createElement("footer");
  17. </ script >   
  18. </ head >   
  19.     
  20. < body >   
  21. <header> This is the header </header>   
  22. < content > This is the middle content area </ content >   
  23. < footer > This is the bottom </ footer >   
  24. </ body >   
  25. </ html >   

Let's talk about something irrelevant. Why should we write HTML in a semantic way?

First, the code is easy to read. When others look at your code, they can understand it at a glance. Second, it is beneficial to SEO. Search engine crawlers will largely ignore the tags used for presentation and only focus on semantic tags.

So, start writing your HTML using semantic tags. It’s not that hard, right?

Appendix 1:

The above article about using semantic tags to write your HTML compatible with IE6, 7, and 8 is all the content that the editor shares with you. I hope it can give you a reference and I also hope that you will support 123WORDPRESS.COM.

Original URL: http://www.cnblogs.com/shouce/p/5385701.html

<<:  SQL Practice Exercise: Online Mall Database User Information Data Operation

>>:  Ubuntu installation Matlab2020b detailed tutorial and resources

Recommend

Detailed explanation of HTML document types

Mine is: <!DOCTYPE html> Blog Garden: <!...

Detailed explanation of command to view log files in Linux environment

Table of contents Preface 1. cat command: 2. more...

Interpretation of CocosCreator source code: engine startup and main loop

Table of contents Preface preparation Go! text St...

Detailed explanation of viewing and setting SQL Mode in MySQL

Viewing and Setting SQL Mode in MySQL MySQL can r...

Explanation of the problem of selecting MySQL storage time type

The datetime type is usually used to store time i...

Teach you to connect to MySQL database using eclipse

Preface Since errors always occur, record the pro...

Double loading issue when the page contains img src

<br />When the page contains <img src=&qu...

Vue2 cube-ui time selector detailed explanation

Table of contents Preface 1. Demand and Effect ne...

Detailed explanation of hosts file configuration on Linux server

Linux server hosts file configuration The hosts f...

HTML basic summary recommendation (title)

HTML: Title Heading is defined by tags such as &l...

Detailed explanation of box-sizing in CSS3 (content-box and border-box)

Box-sizing in CSS3 (content-box and border-box) T...

Detailed explanation of nginx reverse proxy webSocket configuration

Recently, I used the webSocket protocol when work...