HTML and XHTML, concepts of usage


In the previous article, Taimienphi.vn introduced you to the URL in HTML. In the next article below, Taimienphi.vn will introduce you more about HTML and XHTML.


XHTML is HTML written in XML. Refer to the following article of Taimienphi.vn to find out details HTML and XHTML.

Let’s learn about HTML and XHTML

Table of Contents:
1. What is XHTML?
2. Why use XHTML?
3. Differences between HTML and XHTML
4. XHTML DOCTYPE declaration is required
5. XHTML elements must be properly nested
6. XHTML elements must have a closing tag
7. The empty element must also be closed
8. XHTML elements must be written in lowercase
9. Attributes must be cited
10. How to convert HTML to XHTML

first. What is XHTML?

– XHTML stands for EXtensible HyperText Markup Language.

– XHTML is similar to HTML, but more accurate than HTML.

– XHTML is HTML defined as an XML application.

– All major browsers support XHTML.

2. Why use XHTML?

Many websites on the web contain bad HTML.

The following HTML code works well on most web browsers (even if it doesn’t follow HTML rules):

html and xhtml

Today’s web browsers use different technologies. Some browsers are designed to run on computers, some run on mobile devices and other small devices. Usually small devices often lack the resources to translate bad tag markup languages.

XML is a language that marks the language with tags, in which documents must be correctly marked.

XHTML was developed by combining the advantages of HTML and XML.

XHTML is HTML redesigned as XML.

3. Differences between HTML and XHTML

Here are some of the differences between HTML and XHTML:

Document structure

– XHTML DOCTYPE is required.

– Properties xmlns in html is required.

– Tags html, head, title and body is required

XHTML elements

– XHTML elements must be properly nested.

– XHTML elements must have a closing tag.

– XHTML elements must be written in lowercase.

– XHTML document must have an original element.

XHTML attributes

Attribute names must be lowercase.

– Attribute values ​​must be quoted.

4. XHTML DOCTYPE declaration is required

– Declaration is required in XHTML documents XHTML DOCTYPE.

– Also elements html, head, title and body Also required and the xmlns attribute in the html tag must specify the namespace xml for documents.

For example: The following example shows an XHTML document with required tags:

html and xhtml 2

5. XHTML elements must be properly nested

In HTML, SOME The element must be properly nested within other elements, such as:

html and xhtml 3

In XHTML, ALL Elements must be properly nested within other elements, such as:

html and xhtml 4

6. XHTML elements must have a closing tag

Example 1: in the example below the XHTML element has no closing tag, so the result returned an error:

html and xhtml 5

Example 2: in XHTML, elements must have a closing tag like this:

html and xhtml 6

7. The empty element must also be closed

Example 1: In this example, the empty element is not closed, resulting in an error:

html and xhtml 7

Example 2: We must write as below:

html and xhtml 8

8. XHTML elements must be written in lowercase

Example 1: In this example, XHTML elements are written in capital letters resulting in an error:

html and xhtml 9

Example 2: These elements must be written in lower case letters as below:

html and xhtml 10

9. Attributes must be cited

Example 1: In this example, the properties are not quoted, resulting in an error:

html and xhtml 11

Example 2: We must write in the form as below:

html and xhtml 12

10. How to convert HTML to XHTML

To convert HTML to XHTML, follow the steps below:

Step 1: More html and xhtml 13on the first line of every page.

Step 2: Add properties xmlns for the html element of each page.

Step 3: Change all element names in lowercase.

Step 4: Close all empty elements.

Step 5: Change all attribute names to lowercase.

Step 6: Quote all attribute values.

https://thuthuat.taimienphi.vn/html-va-xhtml-50812n.aspx
The article above Taimienphi.vn has just introduced you about HTML and XHTML. Also if there are any questions or questions that need answers like URL in HTML What is it ?, readers can leave their comments in the comment section below the article, Taimienphi.vn will answer your questions as soon as possible.

.

Add a Comment

Your email address will not be published. Required fields are marked *