What is the difference between HTML, XML, and XHTML?

Source: Internet
Author: User
Tags html form

  1. HTML is Hypertext Markup Language (Hyper Text Markup Language), is the first language to write Web pages, but because of the early time, the specification is not very good, mixed case and code is not standardized, is a more loosely-syntactically, not strict web language

  2. XHTML is an upgraded version of HTML (extensible Hyper Text Markup Language), the HTML is standardized, the code is more rigorous and pure, is also a transitional language, HTML transition to XML language. In fact XHTML is not much different from the HTML 4.01 standard.

  3. XML is an Extensible Markup language (extensible Markup Language), a cross-platform language that encodes more freely and can freely create tags (
    For example, create as follows:

    <note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don‘t forget me this weekend!</body></note>

    ), primarily for storing data and structures that can be extended

The difference between HTML and XML:
    • XML is designed to transmit and store data, with the focus on the content of the data.
    • HTML is designed to display data with the focus on the appearance of the data.
    • HTML is designed to display information, while XML is designed to transmit information.
    • XML is case-sensitive when defining tags, while HTML tags are case-insensitive.
The difference between HTML and XHTML:
    • XHTML elements must be nested correctly.

      For example, XHTML has to do this<b><i>This text is bold and italic</i></b>
      In HTML, some elements can be nested incorrectly like this:
      <b><i>This text is bold and italic</b></i>

    • XHTML elements must be closed.

      For example <p>This is a paragraph</p> ===>>, This is right.
      <p>This is a paragraph===>> This is wrong.

    • The label name must be in lowercase letters.

      For example: <p>This is a paragraph</p> ==>>, This is right.
      <P>This is a paragraph</P>===>> This is wrong.

    • The XHTML document must have a root element.

      All XHTML elements must be nested within the root element

    • How to understand HTML semantics?

HTML semantics is to give you a visual understanding of the use and role of tags (markup) and attributes (attribute), choose the right label (code semantics) for developers to read and write more elegant code, while the browser crawler and machine very good parsing, and easy to team development and maintenance.

    • How do you understand the principle of separation of content from style?

When writing HTML, regardless of the style, focus on the structure and semantics of HTML, so that HTML can reflect the structure of the page or content. Then write the style.
When writing JS, try not to use JS to directly manipulate the style, but by adding to the element delete class to control the style changes.
The separation of the document structure from the document style ensures a smooth degradation of the Web page and allows the content and style to be independently edited separately.

    • What are the common meta tags?
  • Specifying a character Set
    <meta charset="utf-8">

  • Describe your page's keywords to the search engine
    <meta name="keywords" content="">

  • Tell the search engine the main content of your site
    <meta name="description" content="">

  • Tell the search engine the author of your site's production
    <meta name="author" content="your name">

  • Responsive page
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

  • Timed to allow the page to jump to the Mozilla homepage within 3 seconds (the http-equiv property provides a name for the name/value pair.) and instructs the server to include a name/value pair in the header of the MIME document to be routed to the browser before sending the actual document. )
    <meta http-equiv="refresh" content="3" url=https://www.mozilla.org">

  • If a GCF (Google Chrome Frame) is installed, the page is rendered using GCF ("chrome=1"), and if no GCF is installed, the highest version of the IE kernel is used for rendering ("Ie=edge"). X-UA-Compatible(which version the browser takes to render the current page)
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

  • Browser's kernel control
    <meta name="renderer" content="webkit|ie-comp|ie-stand">

    • What does a document declaration do?

The document declaration is used to inform the browser of the type used by the current document, so that the browser parser knows what specification to use to parse the document.

    • What does strict mode and promiscuous mode mean?

In strict mode, the browser renders the page with the highest standards it supports.
In promiscuous mode, also known as quirks mode or compatibility mode, the browser parses the code in its own way, and the page is displayed in a more relaxed backward-compatible way. Promiscuous mode typically simulates the behavior of older browsers to prevent old sites from working.

    • The role of <!doctype html>?

It is a HTML5 standard page statement that tells the browser to parse the rendered page with the latest HTML5 standard, and if not, the browser enters promiscuous mode.

    • What is the reason for the browser garbled? How to solve?

The root cause of garbled characters is the saved encoding format and the decoding format mismatch caused by browser parsing.
Workaround: When writing code, Add and save in HTML while <meta charset=‘xxx‘> still choosing the same encoding method.

    • What are the common browsers? What kernel?
  • Internet Explorer is using the Trident

  • Firefox is using the gecko.

  • Opera used to be Presto, and later with Blink

  • Apple's safari, Google Chrome uses WebKit, and most of the dual-core browsers made in China, one of which is webkit.

    • List common labels and briefly describe what they are used for in the scene?

label Application Scenarios
The root element of an HTML page
<body> The contents of the document
Used to define the header of a document
<meta> Metadata is provided. Metadata is not displayed on the page and is parsed by the browser
<title> Title of the document
Defines a heading to level six headings, and the title font size fades
<p> Define a paragraph
<a> Web Links
<div> Block-level element, which can be used to combine containers of other HTML elements without a specific meaning
<span> inline element, also no specific meaning, can be used as a container for text
<u> Underline
<em> Accent Text
<strong> Aggravating text
<ol> Ordered list
<ul> Unordered list
<li> Defining list Items
Image
<br > Line break
<input> Defining an input control
<i> Italic Word
<table> Defining tables
<tr> Define rows in a table
<td> Define cells in a table
<th> Table header for defining tables
<tbody> Defining the body of a table
<tfoot> Define a footer for a table
Create a horizontal line
<iframe> Define an inline frame
<cite> Define the title of the work
<button> Button
<b> Define bold text
<form> To define an HTML form for user input
<caption> Defining table Headings
<footer> Define the footer of a document or section

What is the difference between HTML, XML, and XHTML?

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.