search
HomeWeb Front-endHTML TutorialNew features in HTML5

If XHTML has begun to seek to replace HTML, then the practicality of HTML5 is that it integrates the two syntaxes and uses the same effective way to express HTML's abstract DOM representation. The HTML5 specification combines HTML4, XHTML1, and DOM level 2HTML, and is updated accordingly.

HTML5 replaces XHTML 1 as the XML serialization format of the HTML specification. Developers can format HTML5 documents using either relaxed HTML syntax or strict XML syntax.

HTML5 includes the following new and updated features:

1. Added a new HTML document type:
2. Added some new structural markup elements (

,

1. Painting canvas element

  Methods for defining graphics, drawing paths, rectangles, circles, characters and adding images.

First create the canvas element and specify the id, width and height of the element:

      <canvas id="myCanvas" width="200" height="100"></canvas>
 然后通过javas来绘制。Canvas元素本身没有绘图能力,所有的绘制工作必须在javascript内部完成渐变。
      <script type="text/javascript">
          var c=document.getElementById("myCanvas");
          var cxt=c.getContext("2d");
          cxt.fillStyle="#FF0000";
          cxt.fillRect(0,0,150,75);
      </script>

 JavaScript uses id to find canvas elements:

      var c=document.getElementById("myCanvas");

 Then, create the context object:

      var cxt=c.getContext("2d"); 

 The getContext("2d") object is a built-in HTML5 object with multiple methods for drawing paths, rectangles, circles, characters, and adding images.

The following two lines of code draw a red rectangle:

      cxt.fillStyle="#FF0000";
      cxt.fillRect(0,0,150,75); 

 The fillStyle method dyes it red, and the fillRect method specifies the shape, position and size.

The following two lines of code draw a straight line:

   cxt.moveTo(100,100);

   cxt.lineTo(200,200);

The following line of code draws a circle:

   cxt.arc(70,18,15,0,Math.PI*2,false);

 What do these attribute values ​​correspond to? 70 and 18 are the X-axis and Y-axis respectively, 15 is the radius of the circle, 0 is the angle, Math.PI*2 is the pi ratio, false means clockwise and true means counterclockwise.

The gradient effect of color can also be achieved:

  

    var c=document.getElementById("myCanvas");

    var cxt=c.getContext("2d");

    var grd=cxt.createLinearGradient(0,0,175,50);

    grd.addColorStop(0,"#FF0000");

    grd.addColorStop(1,"#00FF00");

    cxt.fillStyle=grd;

    cxt.fillRect(0,0,175,50);

  

There are some other effects:

  Curve quadraticCurreTo

  Font fillText

2. Audio audio and video video

  Video also supports multiple source elements to link to different video files. The browser will use the first recognized format
  Attribute value:
 Play

 preload="preload"

 muted="mute"

  Volume-=0.1 volume decrease

  Volume+=0.1 volume plus

  currentTime+=10 Fast forward 10 seconds

  currentTime-=10 Go back 10 seconds

  playbackRate=1 accelerate playback (default playback speed)

 The attribute value of audio is the same as that of video

3. Storage

 HTML5 provides two new ways to store data on the client side:

  localStorage - data storage without time limit

  There is no time limit on the data stored by the localStorage method. The data is still available after the next day, week or year.

  sessionStorage - data storage for a session

  The sessionStorage method stores data for a session. The data is deleted when the user closes the browser window.

4. Semantic tags

  
tag defines external content (structural element)

  

5. New form type

1. email

    email 类型用于应该包含 e-mail 地址的输入域。在提交表单时,会自动验证 email 域的值。

    E-mail: type="email" name="user_email" />

  2、url

    url 类型用于应该包含 URL 地址的输入域。在提交表单时,会自动验证 url 域的值。

    Homepage: type="url" name="user_url" />

  3、number

    number 类型用于应该包含数值的输入域。还能够设定对所接受的数字的限定:

    Points: type="number" name="points" min="1" max="10" />

  4、range

    range 类型用于应该包含一定范围内数字值的输入域。

    range 类型显示为滑动条。还能够设定对所接受的数字的限定:

    <input>type="range" name="points" min="1" max="10" />

  5、Date pickers (date, month, week, time, datetime, datetime-local)

    HTML5 拥有多个可供选取日期和时间的新输入类型

    Date: type="date" name="user_date" />

  6、search

    search 类型用于搜索域,比如站点搜索或 Google 搜索。search 域显示为常规的文本域。

  7、color颜色的选择

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software