11.31. HTML5 browser support

发布时间 :2024-02-23 23:00:05 UTC      

You can get some older browsers (which don’t support HTML5) to support HTML5.

11.31.1. HTML5 browser support

Modern browsers support HTML5.

In addition, all browsers, both old and up-to-date, automatically treat unrecognized elements as inline elements.

Because of this, you can “teach” browsers to deal with “unknown” HTML elements.

You can even teach IE6 (Windows XP 2001) browsers to handle unknown HTML elements.

11.31.2. Define a HTML5 element as a block element

HTML5 defines eight new HTML semantic elements. All these elements are block-level elements.

In order for older browsers to display these elements correctly, you can set the CSS’s display property value is block :

Example

header,section,footer,aside,nav,main,article,figure{display:block;}

11.31.3. Add a new element to HTML

You can do it for HTML add a new element.

The instance directs to HTML add a new element and define a style for the element, named <myHero> :

Example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Add new elements to HTML</title>
<script>
document.createElement("myHero")
</script>
<style>
myHero {
    display: block;
    background-color: #ddd;
    padding: 50px;
    font-size: 30px;
}
</style>
</head>

<body>

<h1>My first title</h1>

<p>My first paragraph.</p>

<myHero>My first new element</myHero>

</body>
</html>

JavaScript statement document.createElement("myHero") is to add a new element to the IE browser.

11.31.4. Internet Explorer browser issu

You can use the above methods to add for IE browsers HTML5 element, but:

Browsers of Internet Explorer 8 and earlier IE versions do not support the above methods.

We can use “HTML5 Enabling JavaScript”, “shiv” created by Sjoerd Visscher to solve this problem:

<!--[if lt IE 9]>
  <script
src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

The above code is a comment that reads when the version of the IE browser is less than IE9 html5.js file and parse it.

Note: domestic users please use the static resource library of this site (Google resource library is unstable in China):

<!--[if lt IE 9]>
  <script
src="http://cdn.static.runoob.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]-->

For IE browsers html5shiv is a better solution. html5shiv the main problem is that the new elements proposed by HTML5 are not recognized by IE6-8, these new elements can not be used as parent nodes to wrap child elements, and the CSS style can not be applied.

11.31.5. Perfect Shiv solution

Example

<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>Rendering
HTML5</title><!--[if lt IE 9]> <script
src="http://cdn.static.runoob.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]--></head><body><h1>My First Article</h1><article>Rookie Tutorial ——
Learning is not only about technology, but also about dreams!!!</article></body></html>

html5shiv.js the reference code must be placed in the <head> element, because the IE browser needs to load the file before parsing the new HTML5 element.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.