How to open XHTML? What is the specification content of XHTML? This article will introduce to you in detail how to open HTML and what the content of the specification is.
First let us take a look at how to open XHTML:
Use You can see the effect with a browser, you can see the code with Notepad, or the professional Dreamweaver
xhtml is a language, generally files are html or htm, excluding dynamically generated pages
XHTML writing specification
This is a valid XHTML file writing specification:
A file that conforms to the XHTML standard can be called valid. This can ensure that the XHTML file code Coordination can also make files easier to process without having to ensure consistency in compilation by various browsers. The W3C verification service can verify whether the file is valid. In fact, many website development tools (such as Dreamweaver) support document verification based on W3C standards.
XHTML language must conform to the XML format, for example
Attribute names must be lowercase
错误的:<table WIDTH="100%"> 正确的:<table width="100%">
Use double quotes for attribute values
错误的:<table width=100%> 正确的:<table width="100%">
Attribute abbreviations are not allowed
错误的:<input checked> <input readonly> <input disabled> <option selected> <frame noresize> 正确的:<input checked="checked" /> <input readonly="readonly" /> <input disabled="disabled" /> <option selected="selected" /> <frame noresize="noresize" />
Use the id attribute to replace the name attribute
这是错误的:<img src="picture.gif" name="picture1" /> 这是正确的:<img src="picture.gif" id="picture1" />
Note: For lower version browsers, you should use both the name and id attributes at the same time, and make their values the same , like this:
<img src="picture.gif" id="picture1" name="picture1" />
This is a list of abbreviated attributes in HTML and how they should be written in XHTML:
HTML XHTML compact compact="compact" checked checked="checked" declare declare="declare" readonly readonly="readonly" disabled disabled="disabled" selected selected="selected" defer defer="defer" ismap ismap="ismap" nohref nohref="nohref" noshade noshade="noshade" nowrap nowrap="nowrap" multiple multiple="multiple" noresize noresize="noresize"
The purpose of these practices is to enable an XHTML web page to be Browsers compile correctly and faster. Valid XHTML file
Contents of XHTML specification:
1. All tags must have a corresponding closing tag
In the past in HTML, you could open many tags, such as
and
2. The names of all tag elements and attributes must be in lowercase
Unlike HTML, XHTML is case-sensitive,
3. All XML tags must be nested reasonably
Also because XHTML requires a strict structure, all nesting must be in order. Previously we Code written like this:
/b>
must be modified to:
/p>
That is to say, the nesting layer by layer must be strictly symmetrical.
4. All attributes must be enclosed in quotation marks ""
In HTML, you do not need to add quotation marks to attribute values, but in XHTML, they Must be quoted. For example:
In special cases, you need to use double quotes in the attribute value, you can use " , single quotes can use ', for example:
5. Use encoding to represent all < and & special symbols
Any less than sign (<), which is not part of the tag, must be encoded as <
Any greater than sign (>), which is not part of the tag, must be encoded as Encoded as > ;
Any ampersand (&) that is not part of the entity must be encoded as &
6. Assign a value to all attributes
XHTML stipulates that all attributes must have a value, and if there is no value, it will repeat itself. For example:
Must be changed to:
7. Do not use "--" in the comment content
"--" can only occur at the beginning and end of XHTML comments End, that is, they are no longer valid in the content. For example, the following code is invalid:
Replace the internal dotted lines with equal signs or spaces.