Summary of Seven Basic XHTML Coding Rules

Summary of Seven Basic XHTML Coding Rules
1. All tags must have a corresponding end tag
Previously in HTML, you could open tags such as <p> and <li> without necessarily writing the corresponding </p> and </li> to close them. But this is not legal in XHTML. XHTML requires a strict structure and all tags must be closed. If it is a single unpaired tag, add a "/" at the end of the tag to close it. For example:
<br /><img height="80" alt="Web Designer" src="../images/logo_w3cn_200×80.gif" width="200" />

2. The names of all elements and attributes of tags must be lowercase. <br />Unlike HTML, XHTML is case sensitive. <title> and <TITLE> are different tags. XHTML requires that all tag and attribute names must be lowercase. For example: <BODY> must be written as <body>. Mixing uppercase and lowercase letters is also not recognized. Usually, the attribute name "onMouseOver" automatically generated by Dreamweaver must also be changed to "onmouseover".

3. All XHTML tags must be nested properly
Also, because XHTML requires a strict structure, all nesting must be in order. Previously, we wrote the code like this:
<p><b></p>/b> must be modified to: <p><b></b>/p>
That is to say, the nesting layers must be strictly symmetrical.

4. All attributes must be enclosed in quotation marks ""
In HTML, you don't have to quote attribute values, but in XHTML, they must be quoted. For example:
<height=80> must be changed to: <height="80">
In special cases, you need to use double quotes in the attribute value. You can use ", and single quotes can be used &apos;, for example:
<alt="say&apos;hello&apos;">

5. Encode all < and & special symbols
Any less-than sign (<) that is not part of a tag must be encoded as & lt ;
Any greater-than sign (>) that is not part of a tag must be encoded as &gt;
Any ampersand (&) that is not part of an entity must be encoded as &amp;
Note: There is no space between the above characters.

6. Assign a value to all attributes
XHTML stipulates that all attributes must have a value, and those without a value must repeat themselves. For example:
<td nowrap> <input type="checkbox" name="shirt" value="medium" checked>
Must be modified to:
<td nowrap="nowrap"> <input type="checkbox" name="shirt" value="medium" checked="checked">

7. Don’t use “–” in comments
"–" can only occur at the beginning and end of an XHTML comment, i.e. they are no longer valid within the content. For example, the following code is invalid:
<!–Comment here———–Comment here–>
Replace the internal dashes with equal signs or spaces.
<!–Comment here============Comment here–>
Some of the above specifications may seem strange, but all of these are to make our code have a unified and unique standard to facilitate future data reuse.

<<:  Solution to the problem that mixin does not work in scss (browser cannot compile it)

>>:  I have sorted out some domestic design websites that I think are good.

Recommend

Explanation of the problem that JavaScript strict mode does not support octal

Regarding the issue that JavaScript strict mode d...

JS implements a detailed plan for the smooth version of the progress bar

The progress bar is not smooth I believe that mos...

How to make a List in CocosCreator

CocosCreator version: 2.3.4 Cocos does not have a...

Detailed example of mysql trigger usage

MySQL trigger syntax details: A trigger is a spec...

Detailed explanation of Cgroup, the core principle of Docker

The powerful tool cgroup in the kernel can not on...

How to implement Svelte's Defer Transition in Vue

I recently watched Rich Harris's <Rethinki...

Implementation of fuzzy query like%% in MySQL

1, %: represents any 0 or more characters. It can...

Pure CSS to achieve cloudy weather icon effect

Effect The effect is as follows ​ Implementation ...

How to enable TLS and CA authentication in Docker

Table of contents 1. Generate a certificate 2. En...

JavaScript to achieve a simple page countdown

This article example shares the specific code of ...

JS cross-domain XML--with AS URLLoader

Recently, I received a requirement for function ex...

Summary of common Linux distribution mirror source configuration

I have been researching Linux recently and tried ...

Solution to index failure caused by MySQL implicit type conversion

Table of contents question Reproduction Implicit ...

JavaScript uses canvas to draw coordinates and lines

This article shares the specific code of using ca...