Basics tutorial web front-end development of HTML5 browser support

Currently on the market there are many versions of the browser, you can let some older browsers (does not support HTML5) support HTML5.


HTML5 browser support

Modern browsers support HTML5.

In addition, all browsers, including old and new, of the unrecognized element is automatically treated as inline elements.

Because of this, you can  "church"  browser process  "unknown"  HTML elements.

Note You can even church IE6 (Windows XP 2001) browser handles HTML elements unknown.

The element is defined as block elements HTML5

HTML5 set eight new HTML  semantics (Semantic)   elements. All of these elements are block-level  elements.

In order to allow older versions of the browser to display these elements correctly, you can set the CSS  display  property value  Block :

Examples

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

Create a front-end learning qun438905713, most in the group are zero-based learners, we help each other, answer each other, and also to prepare a lot of learning materials, welcomed the zero-based junior partner to the exchange.


Adding a new element to HTML

You can add new elements to HTML.

Examples of the new element added to the HTML, and style elements defined for the element named  <MyHero>  :

Examples

<! DOCTYPE HTML>
<HTML>
<head>
<Meta charset = "UTF-. 8">
<title> Add a new element is the HTML </ title>
  <Script> document.createElement ( "MyHero") </ Script>
  <style >
  MyHero {
    the display: Block;
    background-Color: #ddd;
    padding: 50px;
    font-size: 30px;
  } 
  </ style> 
</ head>

<body>

<h1 of> my first title </ h1 of>

< p> my first paragraph. </ the p->

<MyHero> My first new element </ MyHero>

</ body>
</ HTML>


try it"

JavaScript statement  document.createElement ( "myHero")  in order to add new elements to the IE browser.


Internet Explorer browser issues

You can use the above method to add HTML5 elements IE browser, but:

Note Internet Explorer 8 and earlier versions of IE browser does not support more than fashion.

We can use "HTML5 Enabling JavaScript" Sjoerd Visscher created, "  Shiv " to solve the problem:

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

This code is a comment, when the version of the function is less than IE9 IE browser reads html5.js file and parses it.

Note: domestic users use Baidu static repository (Google repository instability in the country):

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

For IE browser html5shiv is a better solution. html5shiv main solution proposed new HTML5 elements are not IE6-8 recognize that these new elements can not be wrapped as a parent child elements, and can not apply CSS styles.


Shiv perfect solution

Examples

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Styling HTML5</title>
  <!--[if lt IE 9]>
  <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
  <![endif]-->
</head>

<body>

<h1>我的第一篇文章</h1>

<article>
学技术,从W3Cschool开始!
</article>

</body>
</html>


try it"

html5shiv.js reference code must be placed   <head>  element, because the IE browser when parsing HTML5 elements need to load the new file.

About the new HTML5 elements, we will be in " HTML new elements to make a detailed presentation" section!

Published 10 original articles · won praise 0 · Views 5042

Guess you like

Origin blog.csdn.net/html886/article/details/104457238