The difference between html4 and html5.

Source: Internet
Author: User

The difference between html4 and html5.

1.html 5 syntax change

HTML5 simplifies many subtle syntaxes, such:

1.1doctype statement;

Html4:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"         "http://www.w3.org/TR/html4/loose.dtd">

Html5:

<!DOCUTYPE html>

1.2 character encoding:

Html4:

<meta http-equiv="content-type" content="text/html;charset=utf-8" />

Html5:

<meta charset="utf-8" />

HTML5 syntax is compatible with HTML4 and XHTML1, but not SGML (standard common Markup Language ). Html5 is backward compatible

To display the HTML 4 content;

1.3 element tag

Elements of the write end mark are not allowed: br, embed, hr, img, input, link, meta, And param. Correct format: <element/>

<br/>

 

1.4 attributes with boolean values

<! -- Write only the attribute and do not write the attribute value. The attribute is true --> <input type = "checkbox" checked/> <br/> <! -- No attribute is written. The attribute is false. --> <input type = "checkbox"/> <br/> <! -- Property value = property name, property is true --> <input type = "checkbox" checked = "checked"/> <br/> <! -- Property value = Null String, property is true --> <input type = "checkbox" checked = ""/>

1.5 omit quotation marks

<Input type = button value = click>

 

 

2. Global attributes (attributes that can be used by all tags)

1. contentEditable attribute. Users can edit the text, which is a Boolean value. true indicates editable, and false indicates editable. The default value is true.
2. designMode attribute. specifies whether the page can be edited. The value is on/off, The on is editable, And the off page cannot be edited. It must be used in javascript.
3. hidden attributes
4. spellcheck attributes. For text spelling check of the input and textarea labels, a message is displayed if a spelling error occurs.
5. The tabindex attribute specifies the selection sequence after the tab key. By default, the tab key is used for link elements and form forms,
You can use the tabindex attribute to enable other labels to obtain the focus by pressing the Tab key. If the value is-1, the focus is not obtained.

3. HTML5 New Elements

3.1 new principal structure elements: artical, aside, section, nav, time, pubdate

The artical tag is usually a document, an independent part of the page, a blog, an article, or other independent part. It can usually be used to represent plug-ins and can be nested.
<! -- The artical tag usually indicates a document, an independent part of the page, a blog, an article, or other independent part. It can usually be used to represent a plug-in, nesting --> <article> 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.