A brief introduction to the differences between HTML and XHTML, and HTML4 and HTML5 tags

A brief introduction to the differences between HTML and XHTML, and HTML4 and HTML5 tags

Difference between HTML and XHTML
1. XHTML elements must be nested correctly
2. XHTML elements must be closed, and empty tags must also be closed. Such as

3. XHTML elements must be lowercase

4. XHTML documents must have a root element

5. XHTML attribute names must be lowercase, attribute values ​​must be quoted, and attributes cannot be abbreviated. For example: <input checked="checked" />
6. XHTML uses the id attribute instead of the name attribute.

Note: You should add an extra space before the "/" symbol to make your XHTML compatible with modern browsers.

7. Language attribute (lang) The lang attribute is applied to almost all XHTML elements. It defines the type of language used by the content inside the element. If you use the lang attribute on an element, you must add an additional xml:lang, like this: <div lang="no" xml:lang="no">Heia Norge!</div>

Three XML document types for XHTML 1.0
XHTML 1.0 specifies three XML document types to correspond to the three DTDs mentioned above.

XML/HTML CodeCopy content to clipboard
  1. XHTML 1.0 Strict
  2. <!DOCTYPE html
  3. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >   

Use when: You want clean markup and avoid clutter in presentation. Please use with Cascading Style Sheets.

XML/HTML CodeCopy content to clipboard
  1. XHTML 1.0 Transitional
  2. <!DOCTYPE html
  3. PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >   

Use it when you need to take advantage of the presentation features of HTML and when you need to write XHTML for browsers that do not support Cascading Style Sheets.

XML/HTML CodeCopy content to clipboard
  1. XHTML 1.0 Frameset
  2. <!DOCTYPE html
  3. PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
  4. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >   

Use in this case: When you need to use HTML frames to split the browser window into two or more frames.

HTML4 vs HTML5

HTML5 is very popular recently. Let's take a look at some differences between HTML5 tags and HTML4 tags:
1. Changes in concepts:

HTML5 focuses on content and structure, not on performance

<header>
<hgroup>Navigation related data</hgroup>
</header>
<nav>Menu</nav>
<article>
<h1>Title: HTML5 Special Video Tutorial</h1>

2. Declaration and label:
HTML5 simplifies more declarations and tags, makes detailed provisions for compatibility, abolishes some elements, and adds some elements.
Introduction to HTML5 tag syntax and new tags

(1) Syntax tags:

a. Tags that do not allow writing end characters: area, basebr, col, command, Embed, hr, img, input, keygen, link, meta, param, source, Track, wbr
b. Tags that can omit the end character: li, dt, dd, p, rt, optgroup, option, colgroup, thread, tbody, tr, td, th
c. Tags that can be completely omitted: html, head, body, colgroup, tbody

(2) Add new tags:

The <article> tag defines an article
The <aside> tag defines a sidebar for the content section of a page.
The <audio> tag defines audio content
The <canvas> tag defines an image
The <command> tag defines a command button
The <datalist> tag defines a drop-down list
The <details> tag defines the details of an element
The <dialog> tag defines a dialog box (session box)
The <embed> tag defines external interactive content or plugins
The <figure> tag defines a group of media content and their titles. The <footer> tag defines the bottom of a page or area.
The <header> tag defines the header of a page or a section.
The <hgroup> tag defines information about a block in a file.
The <keygen> tag defines a generated key value in a form
The <mark> tag defines the text to be marked
The <meter> tag defines a measurement within a predefined range
The <nav> tag defines navigation links
The <output> tag defines some output types
The <progress> tag defines the progress of a task.
The <rp> tag is used in Ruby annotations to tell browsers that do not support Ruby elements how to display them.
The <rt> tag defines the interpretation of ruby ​​notations
The <ruby> tag defines ruby ​​notations.
The <section> tag defines a section
The <source> tag defines a media resource
The <time> tag defines a date/time
The <video> tag defines a video

HTML5 Simple Example

XML/HTML CodeCopy content to clipboard
  1. <!DOCTYPE html >     
  2. < head >     
  3. < meta   charset = utf -8 >     
  4. < title > PHP100 Chinese website HTML5 special topic </ title >     
  5. < style   type = "text/css"   rel = "stylesheet" >     
  6. header,nav,article,footer {border:solid 1px #666;padding:5px}
  7. header{width:500px}
  8. nav{float:left;width:60px;height:200px}
  9. article{float:left;width:428px;height:200px}
  10. footer{clear:both;width:500px}
  11. </ style >     
  12. < script   type = "text/javascript" >     
  13. document.createElement('article');
  14. document.createElement('nav');
  15. document.createElement('header');
  16. </ script >     
  17. </ head >     
  18. < body >     
  19. < header >     
  20. < hgroup > Navigation related data </ hgroup >     
  21. </ header >     
  22. < nav > Menu </ nav >     
  23. < article >     
  24. < h1 > HTML5 Special Video Tutorial </ h1 >     
  25. Release date: < time > 09:00 </ time >     
  26. < time   datetime = "2013-2-10" > Chinese New Year </ time >     
  27. < p > Test related content </ p >     
  28. </ article >     
  29. < footer >     
  30. < address > address </ address >     
  31. </ footer >     
  32. </ body >     
  33. </ html >   

<<:  A brief introduction to MySQL functions

>>:  Discussion on default margin and padding values ​​of common elements

Recommend

Introduction to Kubernetes (k8s)

I had always wanted to learn Kubernetes because i...

How to detect Ubuntu version using command line

Method 1: Use the lsb_release utility The lsb_rel...

How to open external network access rights for mysql

As shown below: Mainly execute authorization comm...

Detailed explanation of the life cycle of Angular components (Part 2)

Table of contents 1. View hook 1. Things to note ...

Implementing custom radio and check box functions with pure CSS

1. Achieve the effect 2 Knowledge Points 2.1 <...

Detailed explanation of html-webpack-plugin usage

Recently, I used html-webapck-plugin plug-in for ...

Implementation of Nginx domain name forwarding https access

A word in advance: Suddenly I received a task to ...

How to automatically backup mysql remotely under Linux

Preface: Basically, whether it is for our own use...

Implementation of tomcat deployment project and integration with IDEA

Table of contents 3 ways to deploy projects with ...

CSS code to achieve 10 modern layouts

Preface I watched web.dev's 2020 three-day li...

MySQL series of experience summary and analysis tutorials on NUll values

Table of contents 1. Test Data 2. The inconvenien...

Using System.Drawing.Common in Linux/Docker

Preface After the project is migrated to .net cor...

Use of MySQL stress testing tool Mysqlslap

1. MySQL's own stress testing tool Mysqlslap ...

How to connect to a remote docker server with a certificate

Table of contents 1. Use scripts to encrypt TLS f...

An article tells you how to implement Vue front-end paging and back-end paging

Table of contents 1: Front-end handwritten paging...