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

In-depth understanding of the use of r2dbc in MySQL

Introduction MySQL should be a very common databa...

Detailed analysis of when tomcat writes back the response datagram

The question arises This question arose when I wa...

MySQL Series 11 Logging

Tutorial Series MySQL series: Basic concepts of M...

Installation steps of mysql under linux

1. Download the mysql tar file: https://dev.mysql...

jQuery plugin to implement minesweeper game (2)

This article shares the second article of using j...

The implementation process of long pressing to identify QR code in WeChat applet

Preface We all know that the QR codes in official...

In-depth study of vue2.x--Explanation of the h function

Table of contents Solution, Summarize: vue projec...

Reasons and solutions for MySQL selecting the wrong index

In MySQL, you can specify multiple indexes for a ...

VMware virtual machine three connection methods example analysis

NAT In this way, the virtual machine's networ...

CentOS7 uses rpm package to install mysql 5.7.18

illustrate This article was written on 2017-05-20...

Vue implements calling PC camera to take photos in real time

Vue calls the PC camera to take pictures in real ...

Solve the problem of combining AND and OR in MySQL

As shown below: SELECT prod_name,prod_price FROM ...

HTML multimedia application: inserting flash animation and music into web pages

1. Application of multimedia in HTML_falsh animat...

How to use SVG icons in WeChat applets

SVG has been widely used in recent years due to i...