search
HomeWeb Front-endCSS TutorialWhat is XHTML??_Experience exchange

Foreword:
Nowadays, everyone pays attention to standard website building, and the technology used in standard website building is mainly XHTML+CSS. Now we generally use HTML code, so how should I convert it? And what is the difference between HTML and XHTML? In this tutorial, you will learn the differences between HTML and XHTML, and how to convert HTML to XHTML. After all, XHTML is the direction of development, so I think it is necessary to publish this tutorial on this site. I feel that if you want to use standards, it's better to learn HTML first because it's easier, and then look at this tutorial. At the same time, this is also a continuation of the WEB standard XHTML&CSS I have published.

Introduction to XHTML:
In fact, the standard we are talking about should be XML, so why should we learn XHTML? Because the current HTML code is cumbersome and full of risks, but the XML usage environment is not yet mature, an excessive product has been launched, which is XHTML, which plays a role of ups and downs. Some people also think that XHTML is an upgraded version of HTML, which is actually correct. My understanding is that XHTML is a markup language that makes HTML more standardized, making HTML more powerful and reducing the cumbersome code, especially tables.
XHTML was established as a standard by the international standards organization W3C (World Wide web Consortium) on January 26, 2000. It is considered the latest version of HTML and will gradually replace HTML. All browsers now support XHTML, and XHTML is compatible with HTML 4.0. Some people also think that XHTML is HTML4.01. If you write a standard-compliant website during the learning process, you can pass W3C verification. After passing the verification, you will get a mark, usually XHTML1.0 certification and CSS verification. I don’t know how many websites in China have passed these two verifications at the same time. You can go to http://www.w3.org/ to verify your site. If it meets those two rules, we will give us two pieces of code to add to your webpage to show to others. It shows that you adopted the standard to build the website, awesome!

Why we use XHTML
Let’s look at an HTML that contains an error code, as follows:


This is bad HTML
Bad HTML 

Although it contains error codes, it can still be displayed normally when we browse it in the browser. XML is a markup language, but it requires that any element that appears in a web page should be marked. XML is used to describe the data in the web page, while HTML is used to display the elements in the web page. The various browser technologies we currently use on the Internet, including laptops, mobile phones, etc., all require that some content to be browsed must be correctly tagged. If there are incorrect tags, the display may be particularly confusing or even unable to display properly.
So combining HTML and XML, as well as other technologies, we get a language that is useful now and will be useful in the future - XHTML. When everything is standardized in the future, we will use XHTML correctly formatted tags so that all browsers can execute it correctly, so it is necessary for us to start learning XHTML now.

The difference between XHTML and HTML:
XHTML is a new technology. Before browsers and other software support it, it should be necessary for us to be familiar with this technology. In order for us to better learn XHTML, we should be familiar with HTML4.0. We can download a reference manual to get familiar with it. In order to make it easier for us to learn XHTML, in other words, when we use HTML to write code now, we should try our best to write as few error codes as possible, such as: use lowercase characters to write HTML, and add the end of the tag after each tag. For example:
Welcome to the web teaching website
There must be an end, and we must maintain this rule.
The biggest difference between them is:
1.XHTML elements must be nested correctly.
In HTML, some elements can be nested incorrectly and still display normally, such as:
This text is bold and italic
But in XHTML it must be correct It can be used normally after nesting, such as:
 This text is bold and italic
Note: This error usually occurs in tags when nested multiple levels. Such as:

  • Coffee

  • Tea

    •  
    •  
    • Milk

  • The correct one should be:


Coffee
     
    Tea
  •  

  •  
  • Black tea
       
      Green tea
    •  
    •  

    Milk
  •  
  • Observing the above two pieces of code, we can see that correctly we insert the
  • tag after
    .
XHTML files must have the correct organizational format.
All XHTML should be correctly nested within elements starting with and ending with . Other elements can have child elements, and child elements should be correctly nested within their parent elements. Inside. For example:

...

...
Tag names must be in lowercase letters. Because XHTML documents are XML applications, XML is case-sensitive. The symbols
and are two different tags. For example, the error code:



This is a paragraph
a paragraph

 


All XHTML elements must be closed There cannot be empty elements that are not closed in our code. In fact, it is easier for us to end this point. Should there be an end to the beginning? For example, the error code:

This is a paragraph
This is another paragraph

The correct one is:

This is another paragraph

独立したタグを /> で終了する必要もあります。
例: エラー コード
これは休憩です

ここに水平方向の罫線が入ります:

これが画像です What is XHTML??_Experience exchange
正しいコード:
これは休憩

ここに水平方向のルールがあります:

これが画像です What is XHTML??_Experience exchange
上記の例を通して、基本的に HTML と XHTML の違いがわかりました。次に、変更を試みる必要があります。小文字のタグを使用したり、タグの後に終了タグ記号「/>」を追加したりするなど、現在の HTML は今後変更されます。

XHTML の構文
簡単に言えば、XHTML を記述するときはきれいな HTML 構文を使用する必要があります。
XHTML のその他の構文要件:
属性名は小文字である必要があります。例:
エラー コード:

正しいコード:

属性値は引用符で囲む必要があります。例:
間違ったコード:

正しいコード:

属性の省略形は禁止されています。例:
間違ったコード:




コード:
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
Using Pages CMS for Static Site Content ManagementUsing Pages CMS for Static Site Content ManagementMay 13, 2025 am 09:24 AM

I know, I know: there are a ton of content management system options available, and while I've tested several, none have really been the one, y'know? Weird pricing models, difficult customization, some even end up becoming a whole &

The Ultimate Guide to Linking CSS Files in HTMLThe Ultimate Guide to Linking CSS Files in HTMLMay 13, 2025 am 12:02 AM

Linking CSS files to HTML can be achieved by using elements in part of HTML. 1) Use tags to link local CSS files. 2) Multiple CSS files can be implemented by adding multiple tags. 3) External CSS files use absolute URL links, such as. 4) Ensure the correct use of file paths and CSS file loading order, and optimize performance can use CSS preprocessor to merge files.

CSS Flexbox vs Grid: a comprehensive reviewCSS Flexbox vs Grid: a comprehensive reviewMay 12, 2025 am 12:01 AM

Choosing Flexbox or Grid depends on the layout requirements: 1) Flexbox is suitable for one-dimensional layouts, such as navigation bar; 2) Grid is suitable for two-dimensional layouts, such as magazine layouts. The two can be used in the project to improve the layout effect.

How to Include CSS Files: Methods and Best PracticesHow to Include CSS Files: Methods and Best PracticesMay 11, 2025 am 12:02 AM

The best way to include CSS files is to use tags to introduce external CSS files in the HTML part. 1. Use tags to introduce external CSS files, such as. 2. For small adjustments, inline CSS can be used, but should be used with caution. 3. Large projects can use CSS preprocessors such as Sass or Less to import other CSS files through @import. 4. For performance, CSS files should be merged and CDN should be used, and compressed using tools such as CSSNano.

Flexbox vs Grid: should I learn them both?Flexbox vs Grid: should I learn them both?May 10, 2025 am 12:01 AM

Yes,youshouldlearnbothFlexboxandGrid.1)Flexboxisidealforone-dimensional,flexiblelayoutslikenavigationmenus.2)Gridexcelsintwo-dimensional,complexdesignssuchasmagazinelayouts.3)Combiningbothenhanceslayoutflexibilityandresponsiveness,allowingforstructur

Orbital Mechanics (or How I Optimized a CSS Keyframes Animation)Orbital Mechanics (or How I Optimized a CSS Keyframes Animation)May 09, 2025 am 09:57 AM

What does it look like to refactor your own code? John Rhea picks apart an old CSS animation he wrote and walks through the thought process of optimizing it.

CSS Animations: Is it hard to create them?CSS Animations: Is it hard to create them?May 09, 2025 am 12:03 AM

CSSanimationsarenotinherentlyhardbutrequirepracticeandunderstandingofCSSpropertiesandtimingfunctions.1)Startwithsimpleanimationslikescalingabuttononhoverusingkeyframes.2)Useeasingfunctionslikecubic-bezierfornaturaleffects,suchasabounceanimation.3)For

@keyframes CSS: The most used tricks@keyframes CSS: The most used tricksMay 08, 2025 am 12:13 AM

@keyframesispopularduetoitsversatilityandpowerincreatingsmoothCSSanimations.Keytricksinclude:1)Definingsmoothtransitionsbetweenstates,2)Animatingmultiplepropertiessimultaneously,3)Usingvendorprefixesforbrowsercompatibility,4)CombiningwithJavaScriptfo

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

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

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools