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

In-depth analysis of MySQL database transactions and locks

Table of contents 1. Basic Concepts ACID 3.AutoCo...

JavaScript to implement the function of changing avatar

This article shares the specific code of JavaScri...

Detailed tutorial on uploading and configuring jdk and tomcat on linux

Preparation 1. Start the virtual machine 2. git t...

Linux uses dual network card bond and screwdriver interface

What is bond NIC bond is a technology that is com...

Vue3.0 implements the encapsulation of the drop-down menu

Vue3.0 has been out for a while, and it is necess...

JavaScript canvas text clock

This article example shares the specific code of ...

Detailed explanation of system input and output management in Linux

Management of input and output in the system 1. U...

Improvements to the web server to improve website performance

<br />In the first section of this series, w...

Vue implements two routing permission control methods

Table of contents Method 1: Routing meta informat...

jQuery simulates picker to achieve sliding selection effect

This article shares the specific code of jQuery t...

Detailed explanation of semiotics in Html/CSS

Based on theories such as Saussure's philosop...

Getting Started Tutorial for Beginners: Domain Name Resolution and Binding

So after registering a domain name and purchasing...

Summary of the use of MySQL date and time functions

This article is based on MySQL 8.0 This article i...

How to install MySQL 5.7 from source code in CentOS 7 environment

This article describes how to install MySQL 5.7 f...